Class LruCache<K,V>

All Implemented Interfaces:

public class LruCache<K,V> extends Object implements Cache<K,V>
  • Constructor Details

    • LruCache

      public LruCache(int maxSize)
  • Method Details

    • getOrCompute

      public V getOrCompute(K key, Supplier<V> valueSupplier)
      Description copied from interface: Cache
      Retrieves an item from the cache by its key. If the item is not present, the supplied lambda expression is used to compute the value and store it in the cache.
      Specified by:
      getOrCompute in interface Cache<K,V>
      key - the key of the item to retrieve.
      valueSupplier - a lambda expression or method reference that supplies the value if it's missing.
      the value associated with the key, either from the cache or computed by the supplied lambda.
    • getUsageStats

      public LruCache.CacheStats getUsageStats()
      Specified by:
      getUsageStats in interface Cache<K,V>