Interface CacheManager

All Known Implementing Classes:
AbstractCacheManager, AbstractTransactionSupportingCacheManager, CaffeineCacheManager, CompositeCacheManager, ConcurrentMapCacheManager, JCacheCacheManager, NoOpCacheManager, SimpleCacheManager, TransactionAwareCacheManagerProxy

public interface CacheManager
Spring's central cache manager SPI.

Allows for retrieving named Cache regions.

Since:
3.1
Author:
Costin Leau, Sam Brannen, Juergen Hoeller
  • Method Summary

    Modifier and Type
    Method
    Description
    Get the cache associated with the given name.
    Get a collection of the cache names known by this manager.
    default void
    Remove all registered caches from this cache manager if possible, re-creating them on demand.
  • Method Details

    • getCache

      @Nullable Cache getCache(String name)
      Get the cache associated with the given name.

      Note that the cache may be lazily created at runtime if the native provider supports it.

      Parameters:
      name - the cache identifier (must not be null)
      Returns:
      the associated cache, or null if such a cache does not exist or could be not created
    • getCacheNames

      Collection<String> getCacheNames()
      Get a collection of the cache names known by this manager.
      Returns:
      the names of all caches known by the cache manager
    • resetCaches

      default void resetCaches()
      Remove all registered caches from this cache manager if possible, re-creating them on demand. After this call, getCacheNames() will possibly be empty and the cache provider will have dropped all cache management state.

      Alternatively, an implementation may perform an equivalent reset on fixed existing cache regions without actually dropping the cache. This behavior will be indicated by getCacheNames() still exposing a non-empty set of names, whereas the corresponding cache regions will not contain cache entries anymore.

      The default implementation calls Cache.clear() on all registered caches, retaining all caches as registered, satisfying the alternative implementation path above. Custom implementations may either drop the actual caches (re-creating them on demand) or perform a more exhaustive reset at the actual cache provider level.

      Since:
      7.0.2
      See Also: