Package com.priint.pubserver.util
Class Cache.CacheImpl
- All Implemented Interfaces:
Serializable,ConcurrentMap<String,,byte[]> Map<String,byte[]>
- Enclosing class:
- Cache
Class implementing cache
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.concurrent.ConcurrentHashMap
ConcurrentHashMap.KeySetView<K extends Object,V extends Object> Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Field Summary
FieldsModifier and TypeFieldDescriptionlongMax size of the cache.longMaximum duration of the cache. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Method to clear the cache.longcurrentSize(String key) Method to check the current size of an object in the cachebooleanMethod to check for equalitylonglonglonglonginthashCode()byte[]Method to put values into the cache.voidMethod to put multiple key-value pairs in the cachebyte[]Method to remove a given value from the cache.booleanMethod 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, valuesMethods inherited from class java.util.AbstractMap
clone
-
Field Details
-
maxBytes
public long maxBytesMax size of the cache. 64 MB per default -
maxDuration
public long maxDurationMaximum duration of the cache. 1 min per default
-
-
Method Details
-
put
Method to put values into the cache. -
clear
public void clear()Method to clear the cache. It also resets the expiration time of the cache. -
remove
Method to remove a given value from the cache. -
remove
Method to remove a given value from the cache.- Specified by:
removein interfaceConcurrentMap<String,byte[]> - Specified by:
removein interfaceMap<String,byte[]> - Overrides:
removein classConcurrentHashMap<String,byte[]> - Parameters:
key- key of the value to be removed from the cachevalue- 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
Method to put multiple key-value pairs in the cache -
equals
Method to check for equality -
hashCode
public int hashCode() -
currentSize
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
-