public class TimedLRUCache<K,V>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected long |
lifeTime
the life time for objects.
|
protected long |
lifeTimeRange
since we add randomness the range for deviations is calculated and held.
|
Constructor and Description |
---|
TimedLRUCache(long defaultLifeTime)
Create a new TimedLRUCache instance.
|
TimedLRUCache(long defaultLifeTime,
double ratio)
Create a new TimedLRUCache instance.
|
Modifier and Type | Method and Description |
---|---|
protected de.bb.util.TimedLRUCache.Valuette<V> |
__sget(K key)
Get a Valuette for the key.
|
protected java.lang.Object |
__sput(K key,
de.bb.util.TimedLRUCache.Valuette<V> v)
Put a Valuette for the specified key.
|
void |
clear()
Removes all keys and values from the underlying cache.
|
V |
get(java.lang.Object key)
Returns the value to the specified key.
|
V |
put(K key,
V value)
Put a value into the cache using the specified key.
|
void |
put(K key,
V value,
long specificLifeTime)
Put a value into the cache using the specified key.
|
V |
remove(java.lang.Object key)
Removes the associated value from the underlying cache.
|
void |
setLifeTime(long defaultLifeTime)
Set the default time out.
|
int |
size()
Returns the size of the underlying cache.
|
java.lang.String |
toString()
Some verbose information about the cache.
|
protected long lifeTime
protected long lifeTimeRange
public TimedLRUCache(long defaultLifeTime)
defaultLifeTime
- the default life time in milliseconds.public TimedLRUCache(long defaultLifeTime, double ratio)
defaultLifeTime
- the default life time in milliseconds.ratio
- define the ratio for the underlying cache.public void setLifeTime(long defaultLifeTime)
defaultLifeTime
- set a new default life time.public void put(K key, V value, long specificLifeTime)
key
- a key object - not null!value
- a value objectspecificLifeTime
- a life time in millisecondspublic V put(K key, V value)
key
- a key object - not null!value
- a value objectpublic V get(java.lang.Object key)
key
- a key object - not null!protected de.bb.util.TimedLRUCache.Valuette<V> __sget(K key)
key
- the keyprotected java.lang.Object __sput(K key, de.bb.util.TimedLRUCache.Valuette<V> v)
key
- the keyv
- the Valuettepublic V remove(java.lang.Object key)
key
- a key object - not null!public void clear()
public int size()
public java.lang.String toString()
toString
in class java.lang.Object