Interface ComputingCache<K,V>


public interface ComputingCache<K,V>
A simple abstraction for computing cache. Implementations are not required to support recursive computations. A cache client must be aware that such computations may result in livelocks, inifinite loops and other undesired situations.
Author:
Martin Kouba
  • Method Details

    • getValue

      V getValue(K key)
      Parameters:
      key -
      Returns:
      the cache value
    • getCastValue

      <T> T getCastValue(Object key)
      Parameters:
      key -
      Returns:
      the cache value cast to the required type
    • getValueIfPresent

      V getValueIfPresent(K key)
      Parameters:
      key -
      Returns:
      the cache value if present (i.e. no computation is performed)
    • size

      long size()
      Returns:
      the size of the cache
    • clear

      void clear()
      Remove all cache entries.
    • invalidate

      void invalidate(Object key)
      Invalidate the entry with the given key. No-op if no such entry exists.
      Parameters:
      key -
    • getAllPresentValues

      Iterable<V> getAllPresentValues()
      Returns:
      an immutable map of entries
    • forEachValue

      void forEachValue(Consumer<? super V> consumer)
      Performs the given action for each cached value.
      Parameters:
      consumer - the given action