Class DefaultCacheAccessService<K extends de.hybris.platform.regioncache.key.CacheKey,V>

java.lang.Object
de.hybris.platform.cpq.productconfig.services.impl.DefaultCacheAccessService<K,V>
Type Parameters:
K - key
V - value
All Implemented Interfaces:
CacheAccessService<K,V>

public class DefaultCacheAccessService<K extends de.hybris.platform.regioncache.key.CacheKey,V> extends Object implements CacheAccessService<K,V>
Default implementation of CacheAccessService which provides direct access to a cache region.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultCacheAccessService(de.hybris.platform.regioncache.region.impl.EHCacheRegion cache)
    Default constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes all elements from cache.
    get(K key)
    Gets a value from the cache for the given key.
    protected de.hybris.platform.regioncache.region.impl.EHCacheRegion
     
    Provide the keys of all values, which are currently in the cache region.
    getWithLoader(K key, de.hybris.platform.regioncache.CacheValueLoader<V> loader)
    Gets a value from the cache using the loader to get the value.
    getWithSupplier(K key, Supplier<V> supplier)
    Gets a value from the cache for the given key.
    void
    put(K key, V value)
    Puts a value into the cache region.
    void
    putIfAbsent(K key, V value)
    Puts a value into the cache region, only if no value with same key already exists.
    void
    remove(K key)
    Removes a value from the cache.

    Methods inherited from class java.lang.Object

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

    • DefaultCacheAccessService

      public DefaultCacheAccessService(de.hybris.platform.regioncache.region.impl.EHCacheRegion cache)
      Default constructor
      Parameters:
      cache - cache region
  • Method Details

    • get

      public V get(K key)
      Description copied from interface: CacheAccessService
      Gets a value from the cache for the given key.
      Specified by:
      get in interface CacheAccessService<K extends de.hybris.platform.regioncache.key.CacheKey,V>
      Parameters:
      key - K of object which should be retrieved from the cache
      Returns:
      the value or null if the value could not be found in the cache
    • getKeys

      public Set<K> getKeys()
      Description copied from interface: CacheAccessService
      Provide the keys of all values, which are currently in the cache region.
      Specified by:
      getKeys in interface CacheAccessService<K extends de.hybris.platform.regioncache.key.CacheKey,V>
      Returns:
      all keys.
    • getWithSupplier

      public V getWithSupplier(K key, Supplier<V> supplier)
      Description copied from interface: CacheAccessService
      Gets a value from the cache for the given key. If the value is not present in the cache the supplier will be called and the returned value will be cached.
      Specified by:
      getWithSupplier in interface CacheAccessService<K extends de.hybris.platform.regioncache.key.CacheKey,V>
      Parameters:
      key - key of value
      supplier - supplier which returns the value
      Returns:
      the value
    • getWithLoader

      public V getWithLoader(K key, de.hybris.platform.regioncache.CacheValueLoader<V> loader)
      Description copied from interface: CacheAccessService
      Gets a value from the cache using the loader to get the value.
      Specified by:
      getWithLoader in interface CacheAccessService<K extends de.hybris.platform.regioncache.key.CacheKey,V>
      Parameters:
      key - the key of the value which has to loaded
      loader - the loader object which is used to load the value
      Returns:
      number of objects currently stored in the cache.
    • put

      public void put(K key, V value)
      Description copied from interface: CacheAccessService
      Puts a value into the cache region.
      Specified by:
      put in interface CacheAccessService<K extends de.hybris.platform.regioncache.key.CacheKey,V>
      Parameters:
      key - key of value
      value - value which is put into the cache
    • putIfAbsent

      public void putIfAbsent(K key, V value)
      Description copied from interface: CacheAccessService
      Puts a value into the cache region, only if no value with same key already exists.
      Specified by:
      putIfAbsent in interface CacheAccessService<K extends de.hybris.platform.regioncache.key.CacheKey,V>
      Parameters:
      key - key of value
      value - value which is put into the cache
    • remove

      public void remove(K key)
      Description copied from interface: CacheAccessService
      Removes a value from the cache. The cached value cannot be longer used.
      Specified by:
      remove in interface CacheAccessService<K extends de.hybris.platform.regioncache.key.CacheKey,V>
      Parameters:
      key - the key of the value which has to be removed from the cache
    • clearCache

      public void clearCache()
      Description copied from interface: CacheAccessService
      Removes all elements from cache.
      Specified by:
      clearCache in interface CacheAccessService<K extends de.hybris.platform.regioncache.key.CacheKey,V>
    • getCache

      protected de.hybris.platform.regioncache.region.impl.EHCacheRegion getCache()