CacheManager implementation that lazily builds ConcurrentMapCache
instances for each getCache request. Also supports a 'static' mode where
the set of cache names is pre-defined through setCacheNames, 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
org. or
org..
ConcurrentMapCache
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private final ConcurrentMap | |
| private boolean | |
| private SerializationDelegate | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public | ConcurrentMapCacheManager()
Construct a dynamic ConcurrentMapCacheManager, lazily creating cache instances as they are being requested. |
| public | ConcurrentMapCacheManager(String... cacheNames)
Construct a static ConcurrentMapCacheManager, managing caches for the specified cache names only. |
| Modifier and Type | Method and Description |
|---|---|
| protected Cache | Returns: the ConcurrentMapCache (or a decorator thereof)the name of the cache name)Create a new ConcurrentMapCache instance for the specified cache name. |
| public Cache | getCache(String
the cache identifier (must not be name)null)Implements org. |
| public Collection | getCacheNames()
Implements org. |
| public boolean | isAllowNullValues()
Return whether this cache manager accepts and converts |
| public boolean | isStoreByValue()
Return whether this cache manager stores a copy of each entry or a reference for all its caches. |
| private void | |
| public void | setAllowNullValues(boolean allowNullValues)
Specify whether to accept and convert |
| public void | setBeanClassLoader(ClassLoader
the owning class loader classLoader)Implements org. class loader to
a bean instance.
|
| public void | setCacheNames(Collection<String> cacheNames)
Specify the set of cache names for this CacheManager's 'static' mode. |
| public void | setStoreByValue(boolean storeByValue)
Specify whether this cache manager stores a copy of each entry ( |
| allowNullValues | back to summary |
|---|---|
| private boolean allowNullValues | |
| cacheMap | back to summary |
|---|---|
| private final ConcurrentMap<String, Cache> cacheMap | |
| dynamic | back to summary |
|---|---|
| private boolean dynamic | |
| serialization | back to summary |
|---|---|
| private SerializationDelegate serialization
| |
| storeByValue | back to summary |
|---|---|
| private boolean storeByValue | |
| ConcurrentMapCacheManager | back to summary |
|---|---|
| public ConcurrentMapCacheManager() Construct a dynamic ConcurrentMapCacheManager, lazily creating cache instances as they are being requested. | |
| ConcurrentMapCacheManager | back to summary |
|---|---|
| public ConcurrentMapCacheManager(String... cacheNames) Construct a static ConcurrentMapCacheManager, managing caches for the specified cache names only. | |
| createConcurrentMapCache | back to summary |
|---|---|
| protected Cache createConcurrentMapCache(String name) Create a new ConcurrentMapCache instance for the specified cache name. | |
| getCache | back to summary |
|---|---|
| public Cache getCache(String name) Implements org. Doc from org. Get the cache associated with the given name. Note that the cache may be lazily created at runtime if the native provider supports it. | |
| getCacheNames | back to summary |
|---|---|
| public Collection Implements org. Doc from org. Get a collection of the cache names known by this manager.
| |
| isAllowNullValues | back to summary |
|---|---|
| public boolean isAllowNullValues() Return whether this cache manager accepts and converts | |
| isStoreByValue | back to summary |
|---|---|
| public 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.
| |
| recreateCaches | back to summary |
|---|---|
| private void recreateCaches() | |
| setAllowNullValues | back to summary |
|---|---|
| public void setAllowNullValues(boolean allowNullValues) Specify whether to accept and convert Default is "true", despite ConcurrentHashMap itself not supporting Note A change of the null-value setting will reset all existing caches, if any, to reconfigure them with the new null-value requirement. | |
| setBeanClassLoader | back to summary |
|---|---|
| public void setBeanClassLoader(ClassLoader classLoader) Implements org. Doc from org. Callback that supplies the bean Invoked after the population of normal bean properties but
before an initialization callback such as
| |
| setCacheNames | back to summary |
|---|---|
| public void setCacheNames(Collection<String> cacheNames) Specify 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 | |
| setStoreByValue | back to summary |
|---|---|
| public void setStoreByValue(boolean storeByValue) Specify whether this cache manager stores a copy of each entry ( 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.
| |