Class Cache.CacheImpl

  • All Implemented Interfaces:
    java.io.Serializable, java.util.concurrent.ConcurrentMap<java.lang.String,​byte[]>, java.util.Map<java.lang.String,​byte[]>
    Enclosing class:
    Cache

    public static class Cache.CacheImpl
    extends java.util.concurrent.ConcurrentHashMap<java.lang.String,​byte[]>
    Class implementing cache
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.concurrent.ConcurrentHashMap

        java.util.concurrent.ConcurrentHashMap.KeySetView<K extends java.lang.Object,​V extends java.lang.Object>
      • 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>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      long maxBytes
      Max size of the cache.
      long maxDuration
      Maximum duration of the cache.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Method to clear the cache.
      long currentSize​(java.lang.String key)
      Method to check the current size of an object in the cache
      boolean equals​(java.lang.Object o)
      Method to check for equality
      long getCurrentBytes()  
      long getExpires()  
      long getMaxBytes()  
      long getMaxDuration()  
      int hashCode()  
      byte[] put​(java.lang.String key, byte[] value)
      Method to put values into the cache.
      void putAll​(java.util.Map<? extends java.lang.String,​? extends byte[]> m)
      Method to put multiple key-value pairs in the cache
      byte[] remove​(java.lang.Object key)
      Method to remove a given value from the cache.
      boolean remove​(java.lang.Object key, java.lang.Object value)
      Method to remove a given value from the cache.
      • Methods inherited from class java.util.concurrent.ConcurrentHashMap

        compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, forEach, forEach, forEach, forEachEntry, forEachEntry, forEachKey, forEachKey, forEachValue, forEachValue, get, getOrDefault, isEmpty, keys, keySet, keySet, mappingCount, merge, newKeySet, newKeySet, putIfAbsent, reduce, reduceEntries, reduceEntries, reduceEntriesToDouble, reduceEntriesToInt, reduceEntriesToLong, reduceKeys, reduceKeys, reduceKeysToDouble, reduceKeysToInt, reduceKeysToLong, reduceToDouble, reduceToInt, reduceToLong, reduceValues, reduceValues, reduceValuesToDouble, reduceValuesToInt, reduceValuesToLong, replace, replace, replaceAll, search, searchEntries, searchKeys, searchValues, size, toString, values
      • Methods inherited from class java.util.AbstractMap

        clone
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • maxBytes

        public long maxBytes
        Max size of the cache. 64 MB per default
      • maxDuration

        public long maxDuration
        Maximum duration of the cache. 1 min per default
    • Method Detail

      • put

        public byte[] put​(java.lang.String key,
                          byte[] value)
        Method to put values into the cache.
        Specified by:
        put in interface java.util.Map<java.lang.String,​byte[]>
        Overrides:
        put in class java.util.concurrent.ConcurrentHashMap<java.lang.String,​byte[]>
        Parameters:
        key - key of the value in the cache
        value - value to be stored in the cache
        Returns:
        temporary file as byte[]
      • clear

        public void clear()
        Method to clear the cache. It also resets the expiration time of the cache.
        Specified by:
        clear in interface java.util.Map<java.lang.String,​byte[]>
        Overrides:
        clear in class java.util.concurrent.ConcurrentHashMap<java.lang.String,​byte[]>
      • remove

        public byte[] remove​(java.lang.Object key)
        Method to remove a given value from the cache.
        Specified by:
        remove in interface java.util.Map<java.lang.String,​byte[]>
        Overrides:
        remove in class java.util.concurrent.ConcurrentHashMap<java.lang.String,​byte[]>
        Parameters:
        key - key of the value to be removed
        Returns:
        temporary file as byte[]
      • remove

        public boolean remove​(java.lang.Object key,
                              java.lang.Object value)
        Method to remove a given value from the cache.
        Specified by:
        remove in interface java.util.concurrent.ConcurrentMap<java.lang.String,​byte[]>
        Specified by:
        remove in interface java.util.Map<java.lang.String,​byte[]>
        Overrides:
        remove in class java.util.concurrent.ConcurrentHashMap<java.lang.String,​byte[]>
        Parameters:
        key - key of the value to be removed from the cache
        value - value to be removed from the cache
        Returns:
        true if the key with a given value existed and has been deleted from the cache. False otherwise.
      • putAll

        public void putAll​(java.util.Map<? extends java.lang.String,​? extends byte[]> m)
        Method to put multiple key-value pairs in the cache
        Specified by:
        putAll in interface java.util.Map<java.lang.String,​byte[]>
        Overrides:
        putAll in class java.util.concurrent.ConcurrentHashMap<java.lang.String,​byte[]>
        Parameters:
        m - - map String (key), byte[](value)
      • equals

        public boolean equals​(java.lang.Object o)
        Method to check for equality
        Specified by:
        equals in interface java.util.Map<java.lang.String,​byte[]>
        Overrides:
        equals in class java.util.concurrent.ConcurrentHashMap<java.lang.String,​byte[]>
        Parameters:
        o - Object to be compared
        Returns:
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Map<java.lang.String,​byte[]>
        Overrides:
        hashCode in class java.util.concurrent.ConcurrentHashMap<java.lang.String,​byte[]>
      • currentSize

        public long currentSize​(java.lang.String key)
        Method to check the current size of an object in the cache
        Parameters:
        key - key of the object to be checked
        Returns:
      • getMaxDuration

        public long getMaxDuration()
        Returns:
        maximum duration of the cache
      • getMaxBytes

        public long getMaxBytes()
        Returns:
        maximum size of the cache
      • getCurrentBytes

        public long getCurrentBytes()
        Returns:
        current size of the cache
      • getExpires

        public long getExpires()
        Returns:
        current expiration time of the cache