Package org.jxmpp.util.cache
Class ExpirationCache<K,V>
- java.lang.Object
-
- org.jxmpp.util.cache.ExpirationCache<K,V>
-
-
Constructor Summary
Constructors Constructor Description ExpirationCache(int maxSize, long defaultExpirationTime)
Construct a new expiration cache.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
boolean
containsKey(Object key)
boolean
containsValue(Object value)
Set<Map.Entry<K,V>>
entrySet()
V
get(Object key)
int
getMaxCacheSize()
Return the maximum cache Size.boolean
isEmpty()
Set<K>
keySet()
V
lookup(K key)
Returns the value of the specified key, ornull
.V
put(K key, V value)
Put a value in the cache.V
put(K key, V value, long expirationTime)
Put a value in the cahce with the specified expiration time in milliseconds.void
putAll(Map<? extends K,? extends V> m)
V
remove(Object key)
Remove a entry with the given key from the cache.void
setDefaultExpirationTime(long defaultExpirationTime)
Set the default expiration time in milliseconds.void
setMaxCacheSize(int maxCacheSize)
Set the maximum cache size.int
size()
Collection<V>
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 Detail
-
ExpirationCache
public ExpirationCache(int maxSize, long defaultExpirationTime)
Construct a new expiration cache.- Parameters:
maxSize
- the maximum size.defaultExpirationTime
- the default expiration time in milliseconds.
-
-
Method Detail
-
setDefaultExpirationTime
public void setDefaultExpirationTime(long defaultExpirationTime)
Set the default expiration time in milliseconds.- Parameters:
defaultExpirationTime
- the default expiration time.
-
put
public V put(K key, V value)
Description copied from interface:Cache
Put a value in the cache.
-
put
public V put(K key, V value, long expirationTime)
Put a value in the cahce 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
public V lookup(K key)
Description copied from interface:Cache
Returns the value of the specified key, ornull
.
-
getMaxCacheSize
public int getMaxCacheSize()
Description copied from interface:Cache
Return the maximum cache Size.- Specified by:
getMaxCacheSize
in interfaceCache<K,V>
- Returns:
- the maximum cache size.
-
setMaxCacheSize
public void setMaxCacheSize(int maxCacheSize)
Description copied from interface:Cache
Set the maximum cache size.- Specified by:
setMaxCacheSize
in interfaceCache<K,V>
- Parameters:
maxCacheSize
- the new maximum cache size.
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceMap<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interfaceMap<K,V>
-
-