Class CacheAccessImpl

java.lang.Object
de.hybris.platform.regioncache.region.impl.EHCacheRegion
de.hybris.platform.sap.core.bol.cache.impl.CacheAccessImpl
All Implemented Interfaces:
de.hybris.platform.regioncache.region.CacheRegion, CacheAccess
Direct Known Subclasses:
MockCacheAccess

public class CacheAccessImpl extends de.hybris.platform.regioncache.region.impl.EHCacheRegion implements CacheAccess
Standard cache implementation class.
  • Field Summary

    Fields inherited from class de.hybris.platform.regioncache.region.impl.EHCacheRegion

    cacheMap, lifecycleCallback, manager, stats
  • Constructor Summary

    Constructors
    Constructor
    Description
    CacheAccessImpl(String name, int maxEntries)
    Standard constructor.
    CacheAccessImpl(String name, int maxEntries, String evictionPolicy)
    Standard constructor.
    CacheAccessImpl(String name, int maxEntries, String evictionPolicy, boolean exclusiveComputation, boolean statsEnabled)
    Standard constructor.
    CacheAccessImpl(String name, int maxEntries, String evictionPolicy, boolean exclusiveComputation, boolean statsEnabled, Long ttlSeconds)
    Standard constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes all elements from cache.
    get(Object key)
    Gets an object from the cache for the given key.
    Provide the keys of all objects, which are currently in the cache region.
    int
    Returns number of objects currently stored in the cache.
    getWithLoader(Object key, de.hybris.platform.regioncache.CacheValueLoader<?> loader)
    Gets an object from the cache using the loader to get the value.
    void
    put(Object key, Object object)
    Puts an object into the cache region.
    void
    putIfAbsent(Object key, Object object)
    Puts an object into the cache region, only if no object with same key already exists.
    void
    Removes an object from the cache.
    void
    setHandledTypes(String[] handledTypes)
     

    Methods inherited from class de.hybris.platform.regioncache.region.impl.EHCacheRegion

    containsKey, createCacheConfiguration, createCacheEventListener, createCacheStatistics, destroy, get, getAllKeys, getCacheMaxEntries, getCacheRegionStatistics, getHandledTypes, getMaxReachedSize, getName, getWithLoader, init, invalidate, isStatsEnabled, registerLifecycleCallback, remove, setStatsEnabled, toString, unwrap

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • CacheAccessImpl

      public CacheAccessImpl(String name, int maxEntries)
      Standard constructor.
      Parameters:
      name - name of the cache region
      maxEntries - maximum number of entries
    • CacheAccessImpl

      public CacheAccessImpl(String name, int maxEntries, String evictionPolicy)
      Standard constructor.
      Parameters:
      name - name of the cache region
      maxEntries - maximum number of entries
      evictionPolicy - eviction policy which is used
    • CacheAccessImpl

      public CacheAccessImpl(String name, int maxEntries, String evictionPolicy, boolean exclusiveComputation, boolean statsEnabled)
      Standard constructor.
      Parameters:
      name - name of the cache region
      maxEntries - maximum number of entries
      evictionPolicy - eviction policy which is used
      exclusiveComputation - flag indicating if exclusive computation is used
      statsEnabled - flag indicating if statistics are stored or not
    • CacheAccessImpl

      public CacheAccessImpl(String name, int maxEntries, String evictionPolicy, boolean exclusiveComputation, boolean statsEnabled, Long ttlSeconds)
      Standard constructor.
      Parameters:
      name - name of the cache region
      maxEntries - maximum number of entries
      evictionPolicy - eviction policy which is used
      exclusiveComputation - flag indicating if exclusive computation is used
      statsEnabled - flag indicating if statistics are stored or not
      ttlSeconds - time to live of the stored objects in seconds
  • Method Details

    • setHandledTypes

      public void setHandledTypes(String[] handledTypes)
      Overrides:
      setHandledTypes in class de.hybris.platform.regioncache.region.impl.EHCacheRegion
    • get

      public Object get(Object key)
      Description copied from interface: CacheAccess
      Gets an object from the cache for the given key.
      Specified by:
      get in interface CacheAccess
      Parameters:
      key - name of object which should be retrieved from the cache
      Returns:
      the object or null if the object could not be found in the cache
    • getKeys

      public Set<Object> getKeys()
      Description copied from interface: CacheAccess
      Provide the keys of all objects, which are currently in the cache region.
      Specified by:
      getKeys in interface CacheAccess
      Returns:
      all keys.
    • put

      public void put(Object key, Object object) throws SAPHybrisCacheException
      Description copied from interface: CacheAccess
      Puts an object into the cache region.
      Specified by:
      put in interface CacheAccess
      Parameters:
      key - key of object
      object - object which is put into the cache
      Throws:
      SAPHybrisCacheException - thrown if something goes wrong while adding an object to cache
    • putIfAbsent

      public void putIfAbsent(Object key, Object object) throws SAPHybrisCacheException
      Description copied from interface: CacheAccess
      Puts an object into the cache region, only if no object with same key already exists.
      Specified by:
      putIfAbsent in interface CacheAccess
      Parameters:
      key - name of object
      object - object which is put into the cache
      Throws:
      SAPHybrisCacheException - thrown if something goes wrong while adding an object to cache
    • remove

      public void remove(Object key) throws SAPHybrisCacheException
      Description copied from interface: CacheAccess
      Removes an object from the cache. The cached object cannot be longer used.
      Specified by:
      remove in interface CacheAccess
      Parameters:
      key - the name of the object which has to be removed from the cache
      Throws:
      SAPHybrisCacheException - if removing object fails
    • getNumObjects

      public int getNumObjects()
      Description copied from interface: CacheAccess
      Returns number of objects currently stored in the cache.
      Specified by:
      getNumObjects in interface CacheAccess
      Returns:
      number of objects currently stored in the cache.
    • getWithLoader

      public Object getWithLoader(Object key, de.hybris.platform.regioncache.CacheValueLoader<?> loader)
      Description copied from interface: CacheAccess
      Gets an object from the cache using the loader to get the value.
      Specified by:
      getWithLoader in interface CacheAccess
      Parameters:
      key - the name of the object which has to loaded
      loader - the loader object which is used to load the value
      Returns:
      number of objects currently stored in the cache.
    • clearCache

      public void clearCache()
      Description copied from interface: CacheAccess
      Removes all elements from cache.
      Specified by:
      clearCache in interface CacheAccess
      Specified by:
      clearCache in interface de.hybris.platform.regioncache.region.CacheRegion
      Overrides:
      clearCache in class de.hybris.platform.regioncache.region.impl.EHCacheRegion