Class LRUCache<K,V>

java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<K,V>
io.atlasmap.expression.internal.LRUCache<K,V>
Type Parameters:
K - key
V - value
All Implemented Interfaces:
Serializable, Cloneable, Map<K,V>

public class LRUCache<K,V> extends LinkedHashMap<K,V>
A Simple LRU Cache.
See Also:
  • Field Details

    • maxCacheSize

      protected int maxCacheSize
  • Constructor Details

    • LRUCache

      public LRUCache()
      Default constructor for an LRU Cache The default capacity is 10000.
    • LRUCache

      public LRUCache(int maximumCacheSize)
      Constructs a LRUCache with a maximum capacity.
      Parameters:
      maximumCacheSize - maximum cache size
    • LRUCache

      public LRUCache(int initialCapacity, int maximumCacheSize, float loadFactor, boolean accessOrder)
      Constructs an empty LRUCache instance with the specified initial capacity, maximumCacheSize,load factor and ordering mode.
      Parameters:
      initialCapacity - the initial capacity.
      maximumCacheSize - maximum cache size
      loadFactor - the load factor.
      accessOrder - the ordering mode - true for access-order, false for insertion-order.
      Throws:
      IllegalArgumentException - if the initial capacity is negative or the load factor is non-positive.
  • Method Details

    • getMaxCacheSize

      public int getMaxCacheSize()
      Returns:
      Returns the maxCacheSize.
    • setMaxCacheSize

      public void setMaxCacheSize(int maxCacheSize)
      Parameters:
      maxCacheSize - The maxCacheSize to set.
    • removeEldestEntry

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

      protected void onCacheEviction(Map.Entry<K,V> eldest)