Class TestCache<K,​V>

  • All Implemented Interfaces:
    ICache<K,​V>

    public final class TestCache<K,​V>
    extends java.lang.Object
    implements ICache<K,​V>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private ICache<K,​V> cache  
    • Constructor Summary

      Constructors 
      Constructor Description
      TestCache​(ICache<K,​V> cache)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clear the entire cache.
      void clearKey​(K key)
      Clears a specific entry in the cache.
      V get​(K key)
      Retrieve a value from the cache.
      V get​(K key, ICacheEntryValidityChecker<? super K,​? super V> validityChecker)
      Retrieve a value from the cache, using the specified validity checker to ensure the entry is still valid.
      java.util.Set<K> keySet()
      Returns all the keys contained in this cache.
      private java.lang.Object prefix​(K key)  
      void put​(K key, V value)
      Insert a new value into the cache.
      • Methods inherited from class java.lang.Object

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

      • cache

        private final ICache<K,​V> cache
    • Constructor Detail

      • TestCache

        public TestCache​(ICache<K,​V> cache)
    • Method Detail

      • prefix

        private java.lang.Object prefix​(K key)
      • put

        public void put​(K key,
                        V value)
        Description copied from interface: ICache

        Insert a new value into the cache.

        Specified by:
        put in interface ICache<K,​V>
        Parameters:
        key - the key of the new entry
        value - the value to be cached
      • get

        public V get​(K key)
        Description copied from interface: ICache

        Retrieve a value from the cache.

        Specified by:
        get in interface ICache<K,​V>
        Parameters:
        key - the key of the value to be retrieved
        Returns:
        the retrieved value, or null if no value exists for the specified key.
      • get

        public V get​(K key,
                     ICacheEntryValidityChecker<? super K,​? super V> validityChecker)
        Description copied from interface: ICache

        Retrieve a value from the cache, using the specified validity checker to ensure the entry is still valid. If the cache already has a default validity checker, this method should override this setting and use the one specified instead.

        Specified by:
        get in interface ICache<K,​V>
        Parameters:
        key - the key of the value to be retrieved
        validityChecker - the validity checker to be used to ensure the entry is still valid.
        Returns:
        the retrieved value, or null if no value exists for the specified key.
      • clear

        public void clear()
        Description copied from interface: ICache

        Clear the entire cache.

        Specified by:
        clear in interface ICache<K,​V>
      • clearKey

        public void clearKey​(K key)
        Description copied from interface: ICache

        Clears a specific entry in the cache.

        Specified by:
        clearKey in interface ICache<K,​V>
        Parameters:
        key - the key of the entry to be cleared.
      • keySet

        public java.util.Set<K> keySet()
        Description copied from interface: ICache

        Returns all the keys contained in this cache. Note this method might return keys for entries that are already invalid, so the result of calling ICache.get(Object) for these keys might be null.

        Specified by:
        keySet in interface ICache<K,​V>
        Returns:
        the complete set of cache keys. Might include keys for already-invalid (non-cleaned) entries.