Class MemorySafeWindowTinyLFUMap<K,​V>

  • All Implemented Interfaces:
    java.io.Serializable, java.util.Map<K,​V>

    @ThreadSafe
    public class MemorySafeWindowTinyLFUMap<K,​V>
    extends java.util.AbstractMap<K,​V>
    implements java.io.Serializable
    The differences between this class and MemorySafeLRUMap is that this class is thread safe, and it use WindowTinyLFU algorithm provided by caffeine which is better than LRU algorithm.
    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>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cleanUp()
      clean invalidated cache now.
      java.util.Set<java.util.Map.Entry<K,​V>> entrySet()  
      boolean equals​(java.lang.Object o)  
      V get​(java.lang.Object key)  
      int hashCode()  
      void invalidate()
      invalidate coldest cache now.
      boolean isFull()
      whether to full.
      V put​(K key, V value)  
      V remove​(java.lang.Object key)  
      • Methods inherited from class java.util.AbstractMap

        clear, clone, containsKey, containsValue, isEmpty, keySet, putAll, size, toString, values
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
    • Constructor Detail

      • MemorySafeWindowTinyLFUMap

        public MemorySafeWindowTinyLFUMap​(int maxFreeMemory,
                                          int initialSize)
      • MemorySafeWindowTinyLFUMap

        public MemorySafeWindowTinyLFUMap​(int maxFreeMemory,
                                          int initialSize,
                                          long expireAfterWrite,
                                          long maximumSize)
    • Method Detail

      • get

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

        public V put​(K key,
                     V value)
        Specified by:
        put in interface java.util.Map<K,​V>
        Overrides:
        put in class java.util.AbstractMap<K,​V>
      • remove

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

        public java.util.Set<java.util.Map.Entry<K,​V>> entrySet()
        Specified by:
        entrySet in interface java.util.Map<K,​V>
        Specified by:
        entrySet in class java.util.AbstractMap<K,​V>
      • cleanUp

        public void cleanUp()
        clean invalidated cache now.
      • invalidate

        public void invalidate()
        invalidate coldest cache now.
      • isFull

        public boolean isFull()
        whether to full.
        Returns:
        true if it's full
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface java.util.Map<K,​V>
        Overrides:
        equals in class java.util.AbstractMap<K,​V>
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Map<K,​V>
        Overrides:
        hashCode in class java.util.AbstractMap<K,​V>