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 Details

    • builder

      @Autowired protected JCacheConfigurationBuilder builder
    • cacheManager

      protected javax.cache.CacheManager cacheManager
  • Constructor Details

    • DefaultJCacheUtil

      @Autowired public DefaultJCacheUtil(javax.cache.CacheManager cacheManager)
    • DefaultJCacheUtil

      public DefaultJCacheUtil(String uri)
    • DefaultJCacheUtil

      public DefaultJCacheUtil(URI uri)
  • Method Details

    • getCacheManager

      public javax.cache.CacheManager getCacheManager()
      Specified by:
      getCacheManager in interface JCacheUtil
    • 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 interface JCacheUtil
      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 interface JCacheUtil
      Returns:
    • getCache

      public <K, V> javax.cache.Cache<K,V> getCache(String cacheName)
      Description copied from interface: JCacheUtil
      Returns the cache associated with the name or null if no cache exists.
      Specified by:
      getCache in interface JCacheUtil
      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 -