Class LRUCache<K,​V>

  • All Implemented Interfaces:
    Serializable, Cloneable, Map<K,​V>

    public class LRUCache<K,​V>
    extends LinkedHashMap<K,​V>
    An LRU implementation which limits the maximum number of entries and ejects older entries. Null values are not permitted in this implementation.
    See Also:
    Serialized Form
    • Constructor Detail

      • LRUCache

        public LRUCache​(int maxSize)
        Public constructor
        Parameters:
        maxSize -
    • Method Detail

      • update

        public void update​(LinkedHashMap<K,​V> updates)
        Update this LRU with the updates in the given LinkedHashMap, which we use because we apply the updates in a specific order (as defined by the entrySet of the updates parameter).
        Parameters:
        updates -
      • update

        public void update​(List<K> updates)
        Update the LRU by processing each of the keys in the updates parameter
        Parameters:
        updates -
      • newUpdateMap

        public LinkedHashMap<K,​V> newUpdateMap()
        Create a new instance of a LinkedHashMap which can be used for collecting updates to apply to the cache.
        Returns:
        a new empty instance of a LinkedHashMap