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.
- All Implemented Interfaces:
java.util.Map<K,V>
,Cache<K,V>
public class ExpirationCache<K,V> extends java.lang.Object implements Cache<K,V>, java.util.Map<K,V>
A cache which expires its values.
-
-
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(java.lang.Object key)
boolean
containsValue(java.lang.Object value)
java.util.Set<java.util.Map.Entry<K,V>>
entrySet()
V
get(java.lang.Object key)
int
getMaxCacheSize()
Return the maximum cache Size.boolean
isEmpty()
java.util.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 cache with the specified expiration time in milliseconds.void
putAll(java.util.Map<? extends K,? extends V> m)
V
remove(java.lang.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()
java.util.Collection<V>
values()
-
-
-
Method Detail
-
setDefaultExpirationTime
public final 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 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
public V lookup(K key)
Description copied from interface:Cache
Returns the value of the specified key, ornull
.
-
remove
public V remove(java.lang.Object key)
Remove a entry with the given key from the cache.
-
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(java.lang.Object key)
-
containsValue
public boolean containsValue(java.lang.Object value)
-
values
public java.util.Collection<V> values()
-
-