edu.northwestern.at.utils.cache

## Class LRUCache<K,V>

- java.lang.Object
- - java.util.AbstractMap<K,V>
  - - java.util.HashMap<K,V>
    - - java.util.LinkedHashMap<K,V>
      - - edu.northwestern.at.utils.cache.LRUCache<K,V>

- All Implemented Interfaces:
    Cache<K,V>, java.io.Serializable, java.lang.Cloneable, java.util.Map<K,V>

      public class LRUCache<K,V>
      extends java.util.LinkedHashMap<K,V>
      implements Cache<K,V>

  Fixed maximum size cache employing least-recently used method to age entries.
  See Also:
    Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.util.AbstractMap

      `java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `maxEntries` Maximum number of entries in cache.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LRUCache(int maxEntries)` Create a new cache.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected boolean` | `removeEldestEntry(java.util.Map.Entry<K,V> lruEntry)` See if we should delete the least recently used entry.

    - ### Methods inherited from class java.util.LinkedHashMap

      `clear, containsValue, get`

    - ### Methods inherited from class java.util.HashMap

      `clone, containsKey, entrySet, isEmpty, keySet, put, putAll, remove, size, values`

    - ### Methods inherited from class java.util.AbstractMap

      `equals, hashCode, toString`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface edu.northwestern.at.utils.cache.Cache

      `clear, containsKey, get, put, remove, size`

    - ### Methods inherited from interface java.util.Map

      `containsKey, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values`

- - ### Field Detail

    - #### maxEntries

          protected int maxEntries

      Maximum number of entries in cache.

  - ### Constructor Detail

    - #### LRUCache

          public LRUCache(int maxEntries)

      Create a new cache.
      Parameters:
        `maxEntries` - Maximum number of entries allowed.

  - ### Method Detail

    - #### removeEldestEntry

          protected boolean removeEldestEntry(java.util.Map.Entry<K,V> lruEntry)

      See if we should delete the least recently used entry.
      Overrides:
        `removeEldestEntry` in class `java.util.LinkedHashMap<K,V>`
      Returns:
        true if least recently used entry should be removed, false to keep least recently used entry.