Interface Cache<Key,Value>

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

public interface Cache<Key,Value>
An abstraction of a cache for basic use.

For more complex configuration of the cache, use the cache builder of the implementation of choice.

See Also:
  • 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

      @Deprecated default Value getOrFill(Key key, Callable<Value> callable)
      Deprecated.
      Get from cache; if not present, call the Callable to try to fill the cache. This operation should be atomic.
    • get

      Value get(Key key, Function<Key,Value> callable)
      Get from cache; if not present, call the Function to fill the cache slot. 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
    • stats

      default CacheInfo stats()
      Cache statistics (not supported by all caches)