Class SyncLRUMap<K,​V>

  • Type Parameters:
    K -
    V -
    All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.Map<K,​V>

    public class SyncLRUMap<K,​V>
    extends java.util.LinkedHashMap<K,​V>
    Thread-safe LRU map
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
    • Constructor Summary

      Constructors 
      Constructor Description
      SyncLRUMap​(int maxCapacity)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      V get​(java.lang.Object k)  
      V put​(K k, V v)  
      V remove​(java.lang.Object key)  
      protected boolean removeEldestEntry​(java.util.Map.Entry<K,​V> eldest)  
      int size()  
      • Methods inherited from class java.util.LinkedHashMap

        clear, containsValue, entrySet, forEach, getOrDefault, keySet, replaceAll, values
      • Methods inherited from class java.util.HashMap

        clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, putAll, putIfAbsent, remove, replace, replace
      • 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 java.util.Map

        compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, putAll, putIfAbsent, remove, replace, replace
    • Field Detail

      • maxCapacity

        private int maxCapacity
    • Constructor Detail

      • SyncLRUMap

        public SyncLRUMap​(int maxCapacity)
    • Method Detail

      • remove

        public V remove​(java.lang.Object key)
        Specified by:
        remove in interface java.util.Map<K,​V>
        Overrides:
        remove in class java.util.HashMap<K,​V>
      • size

        public int size()
        Specified by:
        size in interface java.util.Map<K,​V>
        Overrides:
        size in class java.util.HashMap<K,​V>
      • put

        public V put​(K k,
                     V v)
        Specified by:
        put in interface java.util.Map<K,​V>
        Overrides:
        put in class java.util.HashMap<K,​V>
      • get

        public V get​(java.lang.Object k)
        Specified by:
        get in interface java.util.Map<K,​V>
        Overrides:
        get in class java.util.LinkedHashMap<K,​V>
      • removeEldestEntry

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