public class SpringCache2kCacheManager extends Object implements org.springframework.cache.CacheManager
CacheManager. The available caches can be
configured programmatically in a Spring configuration class via the use
of addCaches(Function[]), via a Spring XML configuration
and setCaches(Collection) or via the cache2k XML configuration.| Constructor and Description |
|---|
SpringCache2kCacheManager()
Construct a spring cache manager, using the default cache2k cache manager instance.
|
SpringCache2kCacheManager(org.cache2k.CacheManager manager)
Construct a spring cache manager, using a custom cache2k cache manager.
|
SpringCache2kCacheManager(String name)
Construct a spring cache manager, using the cache2k cache manager instance
with the specified name.
|
| Modifier and Type | Method and Description |
|---|---|
SpringCache2kCacheManager |
addCaches(Function<org.cache2k.Cache2kBuilder<?,?>,org.cache2k.Cache2kBuilder<?,?>>... fs)
Adds a caches to this cache manager that maybe is configured via the
Cache2kBuilder. |
SpringCache2kCacheManager |
defaultSetup(Function<org.cache2k.Cache2kBuilder<?,?>,org.cache2k.Cache2kBuilder<?,?>> f)
Function providing default settings for caches added to the manager via
addCaches(java.util.function.Function<org.cache2k.Cache2kBuilder<?, ?>, org.cache2k.Cache2kBuilder<?, ?>>...) |
org.cache2k.extra.spring.SpringCache2kCache |
getCache(String name)
Returns an existing cache or retrieves and wraps a cache from cache2k.
|
Map<String,org.cache2k.extra.spring.SpringCache2kCache> |
getCacheMap()
Expose the map of created and wrapped caches.
|
Collection<String> |
getCacheNames()
Get a list of known caches.
|
org.cache2k.CacheManager |
getNativeCacheManager()
Expose the native cache manager.
|
boolean |
isAllowUnknownCache() |
void |
setAllowUnknownCache(boolean v)
By default the cache manager only manages a cache if added via
addCaches(java.util.function.Function<org.cache2k.Cache2kBuilder<?, ?>, org.cache2k.Cache2kBuilder<?, ?>>...),
setCaches(Collection) or enlisted in the cache2k XML configuration. |
void |
setCaches(Collection<org.cache2k.configuration.Cache2kConfiguration<?,?>> cacheConfigurationList)
Configure the known caches via the configuration bean.
|
public SpringCache2kCacheManager()
CacheManager,
CacheManager.getInstance()public SpringCache2kCacheManager(String name)
CacheManager,
CacheManager.getInstance()public SpringCache2kCacheManager(org.cache2k.CacheManager manager)
CacheManager,
CacheManager.getInstance(String),
CacheManager.getInstance(ClassLoader),
CacheManager.getInstance(ClassLoader, String)public org.cache2k.extra.spring.SpringCache2kCache getCache(String name)
getCache in interface org.springframework.cache.CacheManagerpublic SpringCache2kCacheManager defaultSetup(Function<org.cache2k.Cache2kBuilder<?,?>,org.cache2k.Cache2kBuilder<?,?>> f)
addCaches(java.util.function.Function<org.cache2k.Cache2kBuilder<?, ?>, org.cache2k.Cache2kBuilder<?, ?>>...)@SafeVarargs public final SpringCache2kCacheManager addCaches(Function<org.cache2k.Cache2kBuilder<?,?>,org.cache2k.Cache2kBuilder<?,?>>... fs)
Cache2kBuilder.
The configuration parameter Cache2kBuilder.exceptionPropagator(org.cache2k.integration.ExceptionPropagator<K>)
is managed by this class and cannot be used. This method can be used in case a programmatic
configuration of a cache manager is preferred.
Rationale: The method provides a builder that is already seeded with the effective manager. This makes it possible to use the builder without code bloat. Since the actual build is done within this class, it is also possible to reset specific settings or do assertions.
IllegalArgumentException - if cache is already createdpublic void setCaches(Collection<org.cache2k.configuration.Cache2kConfiguration<?,?>> cacheConfigurationList)
public Collection<String> getCacheNames()
getCacheNames in interface org.springframework.cache.CacheManagerpublic org.cache2k.CacheManager getNativeCacheManager()
public Map<String,org.cache2k.extra.spring.SpringCache2kCache> getCacheMap()
public boolean isAllowUnknownCache()
public void setAllowUnknownCache(boolean v)
addCaches(java.util.function.Function<org.cache2k.Cache2kBuilder<?, ?>, org.cache2k.Cache2kBuilder<?, ?>>...),
setCaches(Collection) or enlisted in the cache2k XML configuration.
Setting this to true will create a cache with a default configuration if the requested
cache name is not known.cache2k API documentation. Copyright © 2000–2019 headissue GmbH, Munich.