K - key typeV - value typepublic class ExpirationCache<K,V> extends java.lang.Object implements CacheElement<K,V>
| Constructor and Description |
|---|
ExpirationCache()
Build an expiration cache of unlimited size.
|
ExpirationCache(int size)
Build an expiration cache with a fixed size.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
callbackOnExpiry(K key,
V value)
Callback function, to be able to react when something is removed.
|
V |
get(K key)
The cached entry is most probably a hash of some sort.
|
java.util.Set<K> |
getKeys()
Get the keys currently in the cache
|
int |
getRefreshTime()
The desired refresh time, in seconds.
|
java.util.List<V> |
getValues()
Get the values in the cache
|
void |
overwrite(K key,
V value,
long lLifetime)
Add a new value in the cache for the given key, overwriting if necessary the previous entry.
|
void |
put(K key,
V value,
long lLifetime)
Put a value in the cache with a maximum lifetime.
|
void |
refresh()
Update the contents of the cache entry.
|
V |
remove(K key)
Remove an entry from the expiration queue
|
int |
size()
Get the cache size
|
public ExpirationCache()
public ExpirationCache(int size)
size - max number of entries in the cache.public V get(K key)
CacheElementget in interface CacheElement<K,V>key - some unique keypublic V remove(K key)
key - public void put(K key, V value, long lLifetime)
key - value - lLifetime - in millisecondsoverwrite(Object, Object, long)public void overwrite(K key, V value, long lLifetime)
callbackOnExpiry(Object, Object) will never be called for the entry that is forcefully removed.key - value - lLifetime - put(Object, Object, long)public int getRefreshTime()
CacheElementCacheElement.refresh() method is called.getRefreshTime in interface CacheElement<K,V>CacheElement.refresh()public void refresh()
CacheElementrefresh in interface CacheElement<K,V>public int size()
public java.util.Set<K> getKeys()
public java.util.List<V> getValues()