Class DefaultEhCacheUtil
java.lang.Object
org.broadleafcommerce.common.extensibility.cache.DefaultJCacheUtil
org.broadleafcommerce.common.extensibility.cache.ehcache.DefaultEhCacheUtil
- All Implemented Interfaces:
JCacheUtil
@Component("blJCacheUtil")
@ConditionalOnEhCache
public class DefaultEhCacheUtil
extends DefaultJCacheUtil
Allows an encapsulated way to create caches programmatically from an EhCache
CacheManager
.
The standard APIs do not provide enough control, so we encapsulate those details here.- Author:
- Kelly Tisdell
-
Field Summary
Fields inherited from class org.broadleafcommerce.common.extensibility.cache.DefaultJCacheUtil
builder, cacheManager
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultEhCacheUtil
(String uri) DefaultEhCacheUtil
(URI uri) DefaultEhCacheUtil
(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.<K,
V> javax.cache.Cache<K, V> Returns the cache associated with the name or null if no cache exists.Methods inherited from class org.broadleafcommerce.common.extensibility.cache.DefaultJCacheUtil
enableManagement, enableStatistics, getCacheManager
-
Constructor Details
-
DefaultEhCacheUtil
-
DefaultEhCacheUtil
@Autowired public DefaultEhCacheUtil(javax.cache.CacheManager cacheManager) -
DefaultEhCacheUtil
-
-
Method Details
-
getCache
Description copied from interface:JCacheUtil
Returns the cache associated with the name or null if no cache exists.- Specified by:
getCache
in interfaceJCacheUtil
- Overrides:
getCache
in classDefaultJCacheUtil
- Returns:
-
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
- Overrides:
createCache
in classDefaultJCacheUtil
- 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
- Overrides:
createCache
in classDefaultJCacheUtil
- Returns:
-