Class CacheAccessInactiveImpl

  • All Implemented Interfaces:
    CacheAccess

    public class CacheAccessInactiveImpl
    extends java.lang.Object
    implements CacheAccess
    Cache implementation class that deactivates the cache implementation such that nothing will be cached.
    The cache will always be empty, even when a put-method is called.
    • Constructor Summary

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clearCache()
      Removes all elements from cache.
      java.lang.Object get​(java.lang.Object key)
      Gets an object from the cache for the given key.
      java.util.Set<java.lang.Object> getKeys()
      Provide the keys of all objects, which are currently in the cache region.
      java.util.Map<java.lang.Object,​java.lang.Object> getMap()
      Convenience method to get access to the empty "Cache".
      int getNumObjects()
      Returns number of objects currently stored in the cache.
      java.lang.Object getWithLoader​(java.lang.Object key, CacheValueLoader<?> loader)
      Gets an object from the cache using the loader to get the value.
      void put​(java.lang.Object name, java.lang.Object object)
      Puts an object into the cache region.
      void putIfAbsent​(java.lang.Object name, java.lang.Object object)
      Puts an object into the cache region, only if no object with same key already exists.
      void remove​(java.lang.Object key)
      Removes an object from the cache.
      void setMap​(java.util.Map<java.lang.Object,​java.lang.Object> map)
      Convenience method to set the empty "Cache".
      • Methods inherited from class java.lang.Object

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

      • CacheAccessInactiveImpl

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

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

        public CacheAccessInactiveImpl​(java.lang.String name,
                                       int maxEntries,
                                       java.lang.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
      • CacheAccessInactiveImpl

        public CacheAccessInactiveImpl​(java.lang.String name,
                                       int maxEntries,
                                       java.lang.String evictionPolicy,
                                       boolean exclusiveComputation,
                                       boolean statsEnabled,
                                       java.lang.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
      • CacheAccessInactiveImpl

        public CacheAccessInactiveImpl()
        Standard constructor.
    • Method Detail

      • getMap

        public java.util.Map<java.lang.Object,​java.lang.Object> getMap()
        Convenience method to get access to the empty "Cache".
        Returns:
        cache map
      • setMap

        public void setMap​(java.util.Map<java.lang.Object,​java.lang.Object> map)
        Convenience method to set the empty "Cache".
        Parameters:
        map - cache map
      • get

        public java.lang.Object get​(java.lang.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 java.util.Set<java.lang.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.
      • 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.
      • put

        public void put​(java.lang.Object name,
                        java.lang.Object object)
                 throws SAPHybrisCacheException
        Description copied from interface: CacheAccess
        Puts an object into the cache region.
        Specified by:
        put in interface CacheAccess
        Parameters:
        name - key 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​(java.lang.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
      • putIfAbsent

        public void putIfAbsent​(java.lang.Object name,
                                java.lang.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:
        name - name of object
        object - object which is put into the cache
        Throws:
        SAPHybrisCacheException - thrown if something goes wrong while adding an object to cache
      • getWithLoader

        public java.lang.Object getWithLoader​(java.lang.Object key,
                                              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