• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

TAKETODAY / today-infrastructure / 20224960533

15 Dec 2025 08:11AM UTC coverage: 84.388% (-0.02%) from 84.404%
20224960533

push

github

TAKETODAY
:white_check_mark: 在测试中排除 jacoco 初始化方法以避免干扰

61869 of 78367 branches covered (78.95%)

Branch coverage included in aggregate %.

145916 of 167860 relevant lines covered (86.93%)

3.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
today-context/src/main/java/infra/cache/CacheManager.java
1
/*
2
 * Copyright 2017 - 2025 the original author or authors.
3
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program. If not, see [https://www.gnu.org/licenses/]
16
 */
17
package infra.cache;
18

19
import org.jspecify.annotations.Nullable;
20

21
import java.util.Collection;
22

23
/**
24
 * Framework's central cache manager SPI.
25
 *
26
 * <p>Allows for retrieving named {@link Cache} regions.
27
 *
28
 * @author Costin Leau
29
 * @author Sam Brannen
30
 * @author TODAY
31
 * @since 2019-01-02 22:44
32
 */
33
public interface CacheManager {
34

35
  /**
36
   * Get the cache associated with the given name.
37
   * <p>Note that the cache may be lazily created at runtime if the
38
   * native provider supports it.
39
   *
40
   * @param name the cache identifier (must not be {@code null})
41
   * @return the associated cache, or {@code null} if such a cache
42
   * does not exist or could be not created
43
   */
44
  @Nullable
45
  Cache getCache(String name);
46

47
  /**
48
   * Get a collection of the cache names known by this manager.
49
   *
50
   * @return the names of all caches known by the cache manager
51
   */
52
  Collection<String> getCacheNames();
53

54
  /**
55
   * Remove all registered caches from this cache manager if possible,
56
   * re-creating them on demand. After this call, {@link #getCacheNames()}
57
   * will possibly be empty and the cache provider will have dropped all
58
   * cache management state.
59
   * <p>Alternatively, an implementation may perform an equivalent reset
60
   * on fixed existing cache regions without actually dropping the cache.
61
   * This behavior will be indicated by {@link #getCacheNames()} still
62
   * exposing a non-empty set of names, whereas the corresponding cache
63
   * regions will not contain cache entries anymore.
64
   * <p>The default implementation calls {@link Cache#clear} on all
65
   * registered caches, retaining all caches as registered, satisfying
66
   * the alternative implementation path above. Custom implementations
67
   * may either drop the actual caches (re-creating them on demand) or
68
   * perform a more exhaustive reset at the actual cache provider level.
69
   *
70
   * @see Cache#clear()
71
   * @since 5.0
72
   */
73
  default void resetCaches() {
74
    for (String cacheName : getCacheNames()) {
×
75
      Cache cache = getCache(cacheName);
×
76
      if (cache != null) {
×
77
        cache.clear();
×
78
      }
79
    }
×
80
  }
×
81
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc