Class Cache.CacheImpl

java.lang.Object
java.util.AbstractMap<K,V>
java.util.concurrent.ConcurrentHashMap<String,byte[]>
com.priint.pubserver.util.Cache.CacheImpl
All Implemented Interfaces:
Serializable, ConcurrentMap<String,byte[]>, Map<String,byte[]>
Enclosing class:
Cache

public static class Cache.CacheImpl extends ConcurrentHashMap<String,byte[]>
Class implementing cache
See Also:
  • Field Details

    • 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 Details

    • put

      public byte[] put(String key, byte[] value)
      Method to put values into the cache.
      Specified by:
      put in interface Map<String,byte[]>
      Overrides:
      put in class ConcurrentHashMap<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 Map<String,byte[]>
      Overrides:
      clear in class ConcurrentHashMap<String,byte[]>
    • remove

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

      public boolean remove(Object key, Object value)
      Method to remove a given value from the cache.
      Specified by:
      remove in interface ConcurrentMap<String,byte[]>
      Specified by:
      remove in interface Map<String,byte[]>
      Overrides:
      remove in class ConcurrentHashMap<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(Map<? extends String,? extends byte[]> m)
      Method to put multiple key-value pairs in the cache
      Specified by:
      putAll in interface Map<String,byte[]>
      Overrides:
      putAll in class ConcurrentHashMap<String,byte[]>
      Parameters:
      m - - map String (key), byte[](value)
    • equals

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

      public int hashCode()
      Specified by:
      hashCode in interface Map<String,byte[]>
      Overrides:
      hashCode in class ConcurrentHashMap<String,byte[]>
    • currentSize

      public long currentSize(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