Interface Cache<Key,Value>

All Known Implementing Classes:
Cache0, Cache1, CacheGuava, CacheSimple, CacheWrapper

public interface Cache<Key,Value>
A cache
  • Method Details

    • 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, 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

      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(BiConsumer<Key,Value> dropHandler)
      Register a callback - called when an object is dropped from the cache (optional operation)