Class LruCache<K,V>

java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<K,V>
com.qubitpi.ws.jersey.template.cache.LruCache<K,V>
Type Parameters:
K - The type of keys maintained by this cache
V - The type of cached values
All Implemented Interfaces:
Serializable, Cloneable, Map<K,V>

@NotThreadSafe public class LruCache<K,V> extends LinkedHashMap<K,V>
LRU Cache.
See Also:
  • Method Details

    • ofSize

      @NotNull public static <K, V> @NotNull LruCache<K,V> ofSize(int cacheSize)
      Creates a new instance of LruCache with the provided maximum number of entries hold in the cache.
      Type Parameters:
      K - The type of keys maintained by this cache
      V - The type of cached values
      Parameters:
      cacheSize - Maximum number of entries in cache
      Returns:
      a new initialized LruCache instance
    • removeEldestEntry

      protected boolean removeEldestEntry(Map.Entry<K,V> eldest)
      Overrides:
      removeEldestEntry in class LinkedHashMap<K,V>