Class Cache0<K,​V>

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

    public final class Cache0<K,​V>
    extends java.lang.Object
    implements Cache<K,​V>
    A cache that keeps nothing
    • Constructor Summary

      Constructors 
      Constructor Description
      Cache0()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()  
      boolean containsKey​(K key)
      Does the cache contain the key?
      V getIfPresent​(K key)
      Get from cache - or return null.
      V getOrFill​(K key, java.util.concurrent.Callable<V> callable)
      Get from cache, of not present, call the Callable to try to fill the cache.
      boolean isEmpty()  
      java.util.Iterator<K> keys()
      Iterate over all keys.
      void put​(K key, V thing)
      Insert into the cache
      void remove​(K key)
      Remove from cache - return true if key referenced an entry
      void setDropHandler​(java.util.function.BiConsumer<K,​V> dropHandler)
      Register a callback - called when an object is dropped from the cache (optional operation)
      long size()
      Current size of cache
      • Methods inherited from class java.lang.Object

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

      • Cache0

        public Cache0()
    • Method Detail

      • containsKey

        public boolean containsKey​(K key)
        Description copied from interface: Cache
        Does the cache contain the key?
        Specified by:
        containsKey in interface Cache<K,​V>
      • getIfPresent

        public V getIfPresent​(K key)
        Description copied from interface: Cache
        Get from cache - or return null.
        Specified by:
        getIfPresent in interface Cache<K,​V>
      • getOrFill

        public V getOrFill​(K key,
                           java.util.concurrent.Callable<V> callable)
        Description copied from interface: Cache
        Get from cache, of not present, call the Callable to try to fill the cache. This operation should be atomic.
        Specified by:
        getOrFill in interface Cache<K,​V>
      • put

        public void put​(K key,
                        V thing)
        Description copied from interface: Cache
        Insert into the cache
        Specified by:
        put in interface Cache<K,​V>
      • remove

        public void remove​(K key)
        Description copied from interface: Cache
        Remove from cache - return true if key referenced an entry
        Specified by:
        remove in interface Cache<K,​V>
      • keys

        public java.util.Iterator<K> keys()
        Description copied from interface: Cache
        Iterate over all keys. Iterating over the keys requires the caller be thread-safe.
        Specified by:
        keys in interface Cache<K,​V>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface Cache<K,​V>
      • clear

        public void clear()
        Specified by:
        clear in interface Cache<K,​V>
      • size

        public long size()
        Description copied from interface: Cache
        Current size of cache
        Specified by:
        size in interface Cache<K,​V>
      • setDropHandler

        public void setDropHandler​(java.util.function.BiConsumer<K,​V> dropHandler)
        Description copied from interface: Cache
        Register a callback - called when an object is dropped from the cache (optional operation)
        Specified by:
        setDropHandler in interface Cache<K,​V>