Class EHCacheRegion

java.lang.Object
de.hybris.platform.regioncache.region.impl.EHCacheRegion
All Implemented Interfaces:
CacheRegion
Direct Known Subclasses:
WebhookDeletedItemCacheRegion

public class EHCacheRegion extends Object implements CacheRegion
Cache region implementation using EHCache.
  • Field Details

    • lifecycleCallback

      protected CacheLifecycleCallback lifecycleCallback
    • manager

      protected net.sf.ehcache.CacheManager manager
    • cacheMap

      protected net.sf.ehcache.Cache cacheMap
    • stats

      protected final CacheStatistics stats
  • Constructor Details

    • EHCacheRegion

      public EHCacheRegion(String name, int maxEntries)
    • EHCacheRegion

      public EHCacheRegion(String name, int maxEntries, String evictionPolicy)
    • EHCacheRegion

      public EHCacheRegion(String name, int maxEntries, String evictionPolicy, boolean exclusiveComputation, boolean statsEnabled)
    • EHCacheRegion

      public EHCacheRegion(String name, int maxEntries, String evictionPolicy, boolean exclusiveComputation, boolean statsEnabled, Long ttlSeconds)
      Constructor that adds possibility to configure TTL seconds for cache elements.
      Parameters:
      ttlSeconds - time to live seconds for cache elements (see EHCache docs for information about how this affects cache operations)
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • createCacheStatistics

      protected CacheStatistics createCacheStatistics()
    • createCacheConfiguration

      protected net.sf.ehcache.config.CacheConfiguration createCacheConfiguration()
    • init

      @PostConstruct public void init()
    • destroy

      @PreDestroy public void destroy()
      Method unregisters cache
    • createCacheEventListener

      protected net.sf.ehcache.event.CacheEventListener createCacheEventListener()
    • get

      public Object get(CacheKey key)
      Description copied from interface: CacheRegion
      Gets value from the cache. If value is absent returns null. Must be thread safe.
      Specified by:
      get in interface CacheRegion
    • getMaxReachedSize

      public long getMaxReachedSize()
      Description copied from interface: CacheRegion
      Returns number of elements currently in the cache
      Specified by:
      getMaxReachedSize in interface CacheRegion
    • getWithLoader

      public Object getWithLoader(CacheKey key, CacheValueLoader loader) throws CacheValueLoadException
      Description copied from interface: CacheRegion
      Gets value from cache. Invokes loader if necessary. Must be thread safe.
      Specified by:
      getWithLoader in interface CacheRegion
      Throws:
      CacheValueLoadException
    • getName

      public String getName()
      Description copied from interface: CacheRegion
      Gets region name. Needed to resolve proper cache region.
      Specified by:
      getName in interface CacheRegion
    • getHandledTypes

      public String[] getHandledTypes()
      Description copied from interface: CacheRegion
      Gets types which can be stored in the region. Needed to resolve proper cache region.
      Special type names are defined in RegionType.
      Specified by:
      getHandledTypes in interface CacheRegion
    • getCacheRegionStatistics

      public CacheStatistics getCacheRegionStatistics()
      Description copied from interface: CacheRegion
      Gets statistics for current region.
      Specified by:
      getCacheRegionStatistics in interface CacheRegion
    • getCacheMaxEntries

      public long getCacheMaxEntries()
      Description copied from interface: CacheRegion
      Gets number of cache entries above which invalidation occurs.
      Specified by:
      getCacheMaxEntries in interface CacheRegion
    • registerLifecycleCallback

      public void registerLifecycleCallback(CacheLifecycleCallback callback)
      Description copied from interface: CacheRegion
      This callback shall be called when eviction occurs.
      Specified by:
      registerLifecycleCallback in interface CacheRegion
    • clearCache

      public void clearCache()
      Description copied from interface: CacheRegion
      Removes all elements from cache.
      Specified by:
      clearCache in interface CacheRegion
    • invalidate

      public Object invalidate(CacheKey key, boolean fireEventsEvenIfNotRemoved)
      Description copied from interface: CacheRegion
      Invalidates (removes) value from cache map. Must be thread safe.
      Specified by:
      invalidate in interface CacheRegion
      Returns:
      an object invalidated from cache.
    • getAllKeys

      public Collection<CacheKey> getAllKeys()
      Description copied from interface: CacheRegion
      Returns all keys currently stored in this region.
      Specified by:
      getAllKeys in interface CacheRegion
    • remove

      public Object remove(CacheKey key, boolean fireEvents)
      Description copied from interface: CacheRegion
      Removes value stored on the key specified. This method does not update statistics. Returns value removed or null.
      Specified by:
      remove in interface CacheRegion
    • setHandledTypes

      public void setHandledTypes(String[] handledTypes)
      Parameters:
      handledTypes - the handledTypes to set
    • containsKey

      public boolean containsKey(CacheKey key)
      Description copied from interface: CacheRegion
      Checks if key is in the cache map.
      Specified by:
      containsKey in interface CacheRegion
    • setStatsEnabled

      public void setStatsEnabled(boolean enabled)
      Specified by:
      setStatsEnabled in interface CacheRegion
    • isStatsEnabled

      public boolean isStatsEnabled()
      Specified by:
      isStatsEnabled in interface CacheRegion
    • unwrap

      public CacheRegion unwrap()