Package io.github.xanthic.cache.spring
Class XanthicSpringCacheManager
java.lang.Object
io.github.xanthic.cache.spring.XanthicSpringCacheManager
- All Implemented Interfaces:
org.springframework.cache.CacheManager
public class XanthicSpringCacheManager
extends Object
implements org.springframework.cache.CacheManager
CacheManager implementation that lazily builds XanthicCache instances for each getCache(java.lang.String) request.
Also supports a 'static' mode where the set of cache names is pre-defined through cacheNames in the constructor, with no dynamic creation of further cache regions at runtime.
The configuration of the underlying cache can be fine-tuned through the CacheApiSpec, passed into this CacheManager in the constructor.
-
Constructor Summary
ConstructorsConstructorDescriptionXanthicSpringCacheManager
(Consumer<io.github.xanthic.cache.core.CacheApiSpec<Object, Object>> spec) XanthicSpringCacheManager will manage all xanthic cache instances for spring.XanthicSpringCacheManager
(Consumer<io.github.xanthic.cache.core.CacheApiSpec<Object, Object>> spec, Collection<String> cacheNames) XanthicSpringCacheManager will manage all xanthic cache instances for spring. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.cache.Cache
@NotNull Collection
<String> Deprecated.void
registerCache
(String name, Consumer<io.github.xanthic.cache.core.CacheApiSpec<Object, Object>> spec) Register a custom xanthic cache by customizing the CacheApiSpec.void
removeCache
(String name) Removes a named cache from this cache manager.
-
Constructor Details
-
XanthicSpringCacheManager
public XanthicSpringCacheManager(Consumer<io.github.xanthic.cache.core.CacheApiSpec<Object, Object>> spec) XanthicSpringCacheManager will manage all xanthic cache instances for spring.- Parameters:
spec
- the default CacheApiSpec used to create a new cache instances
-
XanthicSpringCacheManager
public XanthicSpringCacheManager(Consumer<io.github.xanthic.cache.core.CacheApiSpec<Object, Object>> spec, @Nullable Collection<String> cacheNames) XanthicSpringCacheManager will manage all xanthic cache instances for spring.- Parameters:
spec
- the default CacheApiSpec used to create a new cache instancescacheNames
- If not null, the number of caches and their names will be fixed, with no creation of further cache keys at runtime.
-
-
Method Details
-
getCache
- Specified by:
getCache
in interfaceorg.springframework.cache.CacheManager
-
getCacheNames
- Specified by:
getCacheNames
in interfaceorg.springframework.cache.CacheManager
-
getCustomCacheNames
Deprecated. -
registerCache
public void registerCache(String name, Consumer<io.github.xanthic.cache.core.CacheApiSpec<Object, Object>> spec) Register a custom xanthic cache by customizing the CacheApiSpec.- Parameters:
name
- the name of the cachespec
- configuration for the specified cache
-
removeCache
Removes a named cache from this cache manager.- Parameters:
name
- the name of the cache
-