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 voidclear()booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<K,V>>entrySet()Vget(Object key)intgetMaxCacheSize()Return the maximum cache Size.booleanisEmpty()Set<K>keySet()Vlookup(K key)Returns the value of the specified key, ornull.Vput(K key, V value)Put a value in the cache.Vput(K key, V value, long expirationTime)Put a value in the cahce with the specified expiration time in milliseconds.voidputAll(Map<? extends K,? extends V> m)Vremove(Object key)Remove a entry with the given key from the cache.voidsetDefaultExpirationTime(long defaultExpirationTime)Set the default expiration time in milliseconds.voidsetMaxCacheSize(int maxCacheSize)Set the maximum cache size.intsize()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:CachePut 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:CacheReturns the value of the specified key, ornull.
-
getMaxCacheSize
public int getMaxCacheSize()
Description copied from interface:CacheReturn the maximum cache Size.- Specified by:
getMaxCacheSizein interfaceCache<K,V>- Returns:
- the maximum cache size.
-
setMaxCacheSize
public void setMaxCacheSize(int maxCacheSize)
Description copied from interface:CacheSet the maximum cache size.- Specified by:
setMaxCacheSizein interfaceCache<K,V>- Parameters:
maxCacheSize- the new maximum cache size.
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<K,V>
-
-