Package com.priint.pubserver.util
Class Cache.CacheImpl
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.concurrent.ConcurrentHashMap<java.lang.String,byte[]>
-
- com.priint.pubserver.util.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>
-
-
Field Summary
Fields Modifier and Type Field Description longmaxBytesMax size of the cache.longmaxDurationMaximum duration of the cache.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Method to clear the cache.longcurrentSize(java.lang.String key)Method to check the current size of an object in the cachebooleanequals(java.lang.Object o)Method to check for equalitylonggetCurrentBytes()longgetExpires()longgetMaxBytes()longgetMaxDuration()inthashCode()byte[]put(java.lang.String key, byte[] value)Method to put values into the cache.voidputAll(java.util.Map<? extends java.lang.String,? extends byte[]> m)Method to put multiple key-value pairs in the cachebyte[]remove(java.lang.Object key)Method to remove a given value from the cache.booleanremove(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
-
-
-
-
Method Detail
-
put
public byte[] put(java.lang.String key, byte[] value)Method to put values into the cache.- Specified by:
putin interfacejava.util.Map<java.lang.String,byte[]>- Overrides:
putin classjava.util.concurrent.ConcurrentHashMap<java.lang.String,byte[]>- Parameters:
key- key of the value in the cachevalue- 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:
clearin interfacejava.util.Map<java.lang.String,byte[]>- Overrides:
clearin classjava.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:
removein interfacejava.util.Map<java.lang.String,byte[]>- Overrides:
removein classjava.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:
removein interfacejava.util.concurrent.ConcurrentMap<java.lang.String,byte[]>- Specified by:
removein interfacejava.util.Map<java.lang.String,byte[]>- Overrides:
removein classjava.util.concurrent.ConcurrentHashMap<java.lang.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
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:
putAllin interfacejava.util.Map<java.lang.String,byte[]>- Overrides:
putAllin classjava.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:
equalsin interfacejava.util.Map<java.lang.String,byte[]>- Overrides:
equalsin classjava.util.concurrent.ConcurrentHashMap<java.lang.String,byte[]>- Parameters:
o- Object to be compared- Returns:
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfacejava.util.Map<java.lang.String,byte[]>- Overrides:
hashCodein classjava.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
-
-