Package org.jxmpp.util.cache
Class ExpirationCache<K,V>
java.lang.Object
org.jxmpp.util.cache.ExpirationCache<K,V>
- Type Parameters:
K- the type of the keys of this cache.V- the type of the values this cache caches.
A cache which expires its values.
-
Nested Class Summary
-
Constructor Summary
ConstructorsConstructorDescriptionExpirationCache(int maxSize, long defaultExpirationTime) Construct a new expiration cache. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()intReturn the maximum cache Size.booleanisEmpty()keySet()Returns the value of the specified key, ornull.Put a value in the cache.Put a value in the cache with the specified expiration time in milliseconds.voidRemove a entry with the given key from the cache.final voidsetDefaultExpirationTime(long defaultExpirationTime) Set the default expiration time in milliseconds.voidsetMaxCacheSize(int maxCacheSize) Set the maximum cache size.intsize()values()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
ExpirationCache
Construct a new expiration cache.- Parameters:
maxSize- the maximum size.defaultExpirationTime- the default expiration time in milliseconds.
-
-
Method Details
-
setDefaultExpirationTime
Set the default expiration time in milliseconds.- Parameters:
defaultExpirationTime- the default expiration time.
-
put
Description copied from interface:CachePut a value in the cache. -
put
Put a value in the cache with the specified expiration time in milliseconds.- Parameters:
key- the key of the value.value- the value.expirationTime- the expiration time in milliseconds.- Returns:
- the previous value or
null.
-
lookup
Description copied from interface:CacheReturns the value of the specified key, ornull. -
get
-
remove
Remove a entry with the given key from the cache. -
getMaxCacheSize
Description copied from interface:CacheReturn the maximum cache Size.- Specified by:
getMaxCacheSizein interfaceCache<K,V> - Returns:
- the maximum cache size.
-
setMaxCacheSize
Description copied from interface:CacheSet the maximum cache size.- Specified by:
setMaxCacheSizein interfaceCache<K,V> - Parameters:
maxCacheSize- the new maximum cache size.
-
size
-
isEmpty
-
containsKey
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V>
-
putAll
-
clear
-
keySet
-
values
-
entrySet
-