Class DefaultJCacheUtil
java.lang.Object
org.broadleafcommerce.common.extensibility.cache.DefaultJCacheUtil
- All Implemented Interfaces:
JCacheUtil
- Direct Known Subclasses:
DefaultEhCacheUtil
@Component("blJCacheUtil")
@ConditionalOnEhCacheMissing
public class DefaultJCacheUtil
extends Object
implements JCacheUtil
Default utility to access and programmatically create JCache instances via the JCache
CacheManager
.
Note that this has limited features and functionality based on the fact that the generic JCache (JSR 107) APIs have limited
ability to specify max elements, overflow, etc.- Author:
- Kelly Tisdell
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected JCacheConfigurationBuilder
protected javax.cache.CacheManager
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultJCacheUtil
(String uri) DefaultJCacheUtil
(URI uri) DefaultJCacheUtil
(javax.cache.CacheManager cacheManager) -
Method Summary
Modifier and TypeMethodDescriptioncreateCache
(String cacheName, int ttlSeconds, int maxElementsInMemory) Returns a new Cache with the appropriate cache name, TTL, and maxElements.<K,
V> javax.cache.Cache<K, V> createCache
(String cacheName, int ttlSeconds, int maxElementsInMemory, Class<K> key, Class<V> value) Returns a new Cache with the appropriate cache name, TTL, and maxElements.protected void
enableManagement
(javax.cache.Cache<?, ?> cache) By default this disables management of each cache that is created here.protected void
enableStatistics
(javax.cache.Cache<?, ?> cache) By default this enables statistics for each cache that is created here.<K,
V> javax.cache.Cache<K, V> Returns the cache associated with the name or null if no cache exists.javax.cache.CacheManager
-
Field Details
-
builder
-
cacheManager
protected javax.cache.CacheManager cacheManager
-
-
Constructor Details
-
DefaultJCacheUtil
@Autowired public DefaultJCacheUtil(javax.cache.CacheManager cacheManager) -
DefaultJCacheUtil
-
DefaultJCacheUtil
-
-
Method Details
-
getCacheManager
public javax.cache.CacheManager getCacheManager()- Specified by:
getCacheManager
in interfaceJCacheUtil
-
createCache
public javax.cache.Cache<Object,Object> createCache(String cacheName, int ttlSeconds, int maxElementsInMemory) Description copied from interface:JCacheUtil
Returns a new Cache with the appropriate cache name, TTL, and maxElements. If the cache exists, an exception will be thrown.The ttl and maxElementsInMemory settings may be implementation specific and so implementors may choose to ignore these arguments.
If ttlSeconds is less than 1 then the cache will not expire.
- Specified by:
createCache
in interfaceJCacheUtil
- Returns:
-
createCache
public <K,V> javax.cache.Cache<K,V> createCache(String cacheName, int ttlSeconds, int maxElementsInMemory, Class<K> key, Class<V> value) Description copied from interface:JCacheUtil
Returns a new Cache with the appropriate cache name, TTL, and maxElements. If the cache exists, an exception will be thrown.The ttl and maxElementsInMemory settings may be implementation specific and so implementors may choose to ignore these arguments.
If ttlSeconds is less than 0 then the cache will not expire.
- Specified by:
createCache
in interfaceJCacheUtil
- Returns:
-
getCache
Description copied from interface:JCacheUtil
Returns the cache associated with the name or null if no cache exists.- Specified by:
getCache
in interfaceJCacheUtil
- Returns:
-
enableManagement
protected void enableManagement(javax.cache.Cache<?, ?> cache) By default this disables management of each cache that is created here.- Parameters:
cache
-
-
enableStatistics
protected void enableStatistics(javax.cache.Cache<?, ?> cache) By default this enables statistics for each cache that is created here.- Parameters:
cache
-
-