Interface Cache<Key,​Value>

    • Method Summary

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

      • containsKey

        boolean containsKey​(Key key)
        Does the cache contain the key?
      • getIfPresent

        Value getIfPresent​(Key key)
        Get from cache - or return null.
      • getOrFill

        Value getOrFill​(Key key,
                        java.util.concurrent.Callable<Value> callable)
        Get from cache, of not present, call the Callable to try to fill the cache. This operation should be atomic.
      • put

        void put​(Key key,
                 Value thing)
        Insert into the cache
      • remove

        void remove​(Key key)
        Remove from cache - return true if key referenced an entry
      • keys

        java.util.Iterator<Key> keys()
        Iterate over all keys. Iterating over the keys requires the caller be thread-safe.
      • isEmpty

        boolean isEmpty()
      • clear

        void clear()
      • size

        long size()
        Current size of cache
      • setDropHandler

        void setDropHandler​(java.util.function.BiConsumer<Key,​Value> dropHandler)
        Register a callback - called when an object is dropped from the cache (optional operation)