Class NoopCacheStoreAdapter

  • All Implemented Interfaces:
    CacheStoreAdapter

    public class NoopCacheStoreAdapter
    extends Object
    implements CacheStoreAdapter
    Implementation of a CacheStoreAdapter that uses no data structure and whose operations do nothing. Useful in scenarios where you need a cache reference but don't need to cache anything or it's not appropriate, and when testing or troubleshooting.
    Author:
    Sumer Jabri, Alfonso Vásquez
    • Constructor Detail

      • NoopCacheStoreAdapter

        public NoopCacheStoreAdapter()
    • Method Detail

      • addScope

        public void addScope​(String scope,
                             int maxItemsInMemory)
        Description copied from interface: CacheStoreAdapter
        Adds a new scope to the underlying store.
        Specified by:
        addScope in interface CacheStoreAdapter
        Parameters:
        scope - the name of the scope
        maxItemsInMemory - the maximum number of items in memory, before they are evicted
      • removeScope

        public void removeScope​(String scope)
        Description copied from interface: CacheStoreAdapter
        Removes an existing scope and all the items that are in it.
        Specified by:
        removeScope in interface CacheStoreAdapter
        Parameters:
        scope - scope to remove
      • getSize

        public int getSize​(String scope)
        Description copied from interface: CacheStoreAdapter
        Returns the quantity of items present in the specified scope.
        Specified by:
        getSize in interface CacheStoreAdapter
        Returns:
        the size of the scope (quantity of items)
      • hasKey

        public boolean hasKey​(String scope,
                              Object key)
        Description copied from interface: CacheStoreAdapter
        Returns true if there's and item with the specified key in the specified scope.
        Specified by:
        hasKey in interface CacheStoreAdapter
        Returns:
        true if the key exists in the scope, false otherwise
      • get

        public CacheItem get​(String scope,
                             Object key)
        Description copied from interface: CacheStoreAdapter
        Retrieves an item from a scope.
        Specified by:
        get in interface CacheStoreAdapter
        Parameters:
        scope - scope to get the item from
        key - unique key for the item within this scope
        Returns:
        the requested item if found, null otherwise
      • remove

        public boolean remove​(String scope,
                              Object key)
        Description copied from interface: CacheStoreAdapter
        Removes an item from a scope.
        Specified by:
        remove in interface CacheStoreAdapter
        Parameters:
        scope - scope to remove the item from
        key - unique key for the item within this scope
        Returns:
        true if the removal was successful, false otherwise
      • clearScope

        public void clearScope​(String scope)
        Description copied from interface: CacheStoreAdapter
        Clears the contents of the specified scope in the underlying store.
        Specified by:
        clearScope in interface CacheStoreAdapter
        Parameters:
        scope - scope to clear