Class ConcurrentMapCacheManager
- All Implemented Interfaces:
- Aware,- BeanClassLoaderAware,- CacheManager
CacheManager implementation that lazily builds ConcurrentMapCache
 instances for each getCache(java.lang.String) request. Also supports a 'static' mode where
 the set of cache names is pre-defined through setCacheNames(java.util.Collection<java.lang.String>), with no
 dynamic creation of further cache regions at runtime.
 Supports the asynchronous Cache.retrieve(Object) and
 Cache.retrieve(Object, Supplier) operations through basic
 CompletableFuture adaptation, with early-determined cache misses.
 
Note: This is by no means a sophisticated CacheManager; it comes with no
 cache configuration options. However, it may be useful for testing or simple
 caching scenarios. For advanced local caching needs, consider
 CaffeineCacheManager or
 JCacheCacheManager.
- Since:
- 3.1
- Author:
- Juergen Hoeller
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionConstruct a dynamic ConcurrentMapCacheManager, lazily creating cache instances as they are being requested.ConcurrentMapCacheManager(String... cacheNames) Construct a static ConcurrentMapCacheManager, managing caches for the specified cache names only.
- 
Method SummaryModifier and TypeMethodDescriptionprotected CacheCreate a new ConcurrentMapCache instance for the specified cache name.Get the cache associated with the given name.Get a collection of the cache names known by this manager.booleanReturn whether this cache manager accepts and convertsnullvalues for all of its caches.booleanReturn whether this cache manager stores a copy of each entry or a reference for all its caches.voidremoveCache(String name) Remove the specified cache from this cache manager.voidsetAllowNullValues(boolean allowNullValues) Specify whether to accept and convertnullvalues for all caches in this cache manager.voidsetBeanClassLoader(ClassLoader classLoader) Callback that supplies the beanclass loaderto a bean instance.voidsetCacheNames(Collection<String> cacheNames) Specify the set of cache names for this CacheManager's 'static' mode.voidsetStoreByValue(boolean storeByValue) Specify whether this cache manager stores a copy of each entry (trueor the reference (falsefor all of its caches.
- 
Constructor Details- 
ConcurrentMapCacheManagerpublic ConcurrentMapCacheManager()Construct a dynamic ConcurrentMapCacheManager, lazily creating cache instances as they are being requested.
- 
ConcurrentMapCacheManagerConstruct a static ConcurrentMapCacheManager, managing caches for the specified cache names only.
 
- 
- 
Method Details- 
setCacheNamesSpecify the set of cache names for this CacheManager's 'static' mode.The number of caches and their names will be fixed after a call to this method, with no creation of further cache regions at runtime. Calling this with a nullcollection argument resets the mode to 'dynamic', allowing for further creation of caches again.
- 
setAllowNullValuespublic void setAllowNullValues(boolean allowNullValues) Specify whether to accept and convertnullvalues for all caches in this cache manager.Default is "true", despite ConcurrentHashMap itself not supporting nullvalues. An internal holder object will be used to store user-levelnulls.Note: A change of the null-value setting will reset all existing caches, if any, to reconfigure them with the new null-value requirement. 
- 
isAllowNullValuespublic boolean isAllowNullValues()Return whether this cache manager accepts and convertsnullvalues for all of its caches.
- 
setStoreByValuepublic void setStoreByValue(boolean storeByValue) Specify whether this cache manager stores a copy of each entry (trueor the reference (falsefor all of its caches.Default is "false" so that the value itself is stored and no serializable contract is required on cached values. Note: A change of the store-by-value setting will reset all existing caches, if any, to reconfigure them with the new store-by-value requirement. - Since:
- 4.3
 
- 
isStoreByValuepublic boolean isStoreByValue()Return whether this cache manager stores a copy of each entry or a reference for all its caches. If store by value is enabled, any cache entry must be serializable.- Since:
- 4.3
 
- 
setBeanClassLoaderDescription copied from interface:BeanClassLoaderAwareCallback that supplies the beanclass loaderto a bean instance.Invoked after the population of normal bean properties but before an initialization callback such as InitializingBean'sInitializingBean.afterPropertiesSet()method or a custom init-method.- Specified by:
- setBeanClassLoaderin interface- BeanClassLoaderAware
- Parameters:
- classLoader- the owning class loader
 
- 
getCacheNamesDescription copied from interface:CacheManagerGet a collection of the cache names known by this manager.- Specified by:
- getCacheNamesin interface- CacheManager
- Returns:
- the names of all caches known by the cache manager
 
- 
getCacheDescription copied from interface:CacheManagerGet the cache associated with the given name.Note that the cache may be lazily created at runtime if the native provider supports it. - Specified by:
- getCachein interface- CacheManager
- Parameters:
- name- the cache identifier (must not be- null)
- Returns:
- the associated cache, or nullif such a cache does not exist or could be not created
 
- 
removeCacheRemove the specified cache from this cache manager.- Parameters:
- name- the name of the cache
- Since:
- 6.1.15
 
- 
createConcurrentMapCacheCreate a new ConcurrentMapCache instance for the specified cache name.- Parameters:
- name- the name of the cache
- Returns:
- the ConcurrentMapCache (or a decorator thereof)
 
 
-