Class EmptyCacheMap<K,​V>

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

    public class EmptyCacheMap<K,​V>
    extends java.util.AbstractMap<K,​V>
    implements Cache<K,​V>
    An empty cache map.
    Since:
    9.6.0
    Author:
    jameschu
    • 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>
    • Constructor Summary

      Constructors 
      Constructor Description
      EmptyCacheMap()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Set<java.util.Map.Entry<K,​V>> entrySet()  
      int getLifetime()
      Returns the minimal lifetime, unit=milliseconds.
      int getMaxSize()
      Returns the maximal allowed size.
      V put​(K key, V value)
      Stores an object to the cache.
      void setLifetime​(int lifetime)
      Sets the minimal lifetime.
      void setMaxSize​(int maxsize)
      Sets the maximal allowed size.
      • Methods inherited from class java.util.AbstractMap

        clear, clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, putAll, remove, 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

      • EmptyCacheMap

        public EmptyCacheMap()
    • Method Detail

      • put

        public V put​(K key,
                     V value)
        Description copied from interface: Cache
        Stores an object to the cache.
        Specified by:
        put in interface Cache<K,​V>
        Specified by:
        put in interface java.util.Map<K,​V>
        Overrides:
        put in class java.util.AbstractMap<K,​V>
        Returns:
        the previous value of the same, or null if no such value
      • getLifetime

        public int getLifetime()
        Description copied from interface: Cache
        Returns the minimal lifetime, unit=milliseconds. An mapping won't be removed by GC unless the minimal lifetime or the maximal allowed size exceeds.
        Specified by:
        getLifetime in interface Cache<K,​V>
        See Also:
        Cache.getMaxSize()
      • setLifetime

        public void setLifetime​(int lifetime)
        Description copied from interface: Cache
        Sets the minimal lifetime. Default: Cache.DEFAULT_LIFETIME.
        Specified by:
        setLifetime in interface Cache<K,​V>
        Parameters:
        lifetime - the lifetime, unit=milliseconds; if non-positive, they will be removed immediately.
        See Also:
        Cache.getLifetime()
      • getMaxSize

        public int getMaxSize()
        Description copied from interface: Cache
        Returns the maximal allowed size. Default: Cache.DEFAULT_MAX_SIZE. An mapping won't be removed by GC unless the minimal lifetime or the maximal allowed size exceeds.
        Specified by:
        getMaxSize in interface Cache<K,​V>
        See Also:
        Cache.getLifetime()
      • setMaxSize

        public void setMaxSize​(int maxsize)
        Description copied from interface: Cache
        Sets the maximal allowed size.
        Specified by:
        setMaxSize in interface Cache<K,​V>
        See Also:
        Cache.getMaxSize()
      • 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>