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
ConstructorDescriptionExpirationCache
(int maxSize, long defaultExpirationTime) Construct a new expiration cache. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
int
Return the maximum cache Size.boolean
isEmpty()
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.void
Remove a entry with the given key from the cache.final void
setDefaultExpirationTime
(long defaultExpirationTime) Set the default expiration time in milliseconds.void
setMaxCacheSize
(int maxCacheSize) Set the maximum cache size.int
size()
values()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:Cache
Put 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:Cache
Returns the value of the specified key, ornull
. -
get
-
remove
Remove a entry with the given key from the cache. -
getMaxCacheSize
Description copied from interface:Cache
Return the maximum cache Size.- Specified by:
getMaxCacheSize
in interfaceCache<K,
V> - Returns:
- the maximum cache size.
-
setMaxCacheSize
Description copied from interface:Cache
Set the maximum cache size.- Specified by:
setMaxCacheSize
in interfaceCache<K,
V> - Parameters:
maxCacheSize
- the new maximum cache size.
-
size
-
isEmpty
-
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V>
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,
V>
-
putAll
-
clear
-
keySet
-
values
-
entrySet
-