spring-framework / org.springframework.cache.support / CompositeCacheManager

CompositeCacheManager

open class CompositeCacheManager : CacheManager, InitializingBean

Composite CacheManager implementation that iterates over a given collection of delegate CacheManager instances.

Allows NoOpCacheManager to be automatically added to the end of the list for handling cache declarations without a backing store. Otherwise, any custom CacheManager may play that role of the last delegate as well, lazily creating cache regions for any requested name.

Note: Regular CacheManagers that this composite manager delegates to need to return null from #getCache(String) if they are unaware of the specified cache name, allowing for iteration to the next delegate in line. However, most CacheManager implementations fall back to lazy creation of named caches once requested; check out the specific configuration details for a 'static' mode with fixed cache names, if available.

Author
Costin Leau

Author
Juergen Hoeller

Since
3.1

See Also
#setFallbackToNoOpCacheorg.springframework.cache.concurrent.ConcurrentMapCacheManager#setCacheNames

Constructors

<init>

CompositeCacheManager()

Construct an empty CompositeCacheManager, with delegate CacheManagers to be added via the "cacheManagers" property.

CompositeCacheManager(vararg cacheManagers: CacheManager)

Construct a CompositeCacheManager from the given delegate CacheManagers.

Functions

afterPropertiesSet

open fun afterPropertiesSet(): Unit

getCache

open fun getCache(name: String): Cache

getCacheNames

open fun getCacheNames(): MutableCollection<String>

setCacheManagers

open fun setCacheManagers(cacheManagers: MutableCollection<CacheManager>): Unit

Specify the CacheManagers to delegate to.

setFallbackToNoOpCache

open fun setFallbackToNoOpCache(fallbackToNoOpCache: Boolean): Unit

Indicate whether a NoOpCacheManager should be added at the end of the delegate list. In this case, any getCache requests not handled by the configured CacheManagers will be automatically handled by the NoOpCacheManager (and hence never return null).