|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.util.WeakCache
This is similar to a Hashtable in that you associate values with keys. However only weak references are kept to the keys - which means that the key values can be garbage collected, in which case it will not be possible to access the object values the keys refer to.
The clean() method explicitly removes entries where the keys have been garbage collected.
A background thread is created to clean all existing WeakCache objects at regular intervals. The default interval is 1 minute, but this can be changed by calling setCleanInterval().
| Constructor Summary | |
WeakCache()
|
|
| Method Summary | |
void |
clean()
Remove all entries for which the key has been garbage collected. |
Object |
get(Object key)
|
Iterator |
keys()
Each object returned by the returned Iterator will be a WeakReference. |
void |
put(Object key,
Object data)
|
static void |
setCleanInterval(long interval)
Set the interval between cache cleaning in milliseconds. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, toString |
| Constructor Detail |
public WeakCache()
| Method Detail |
public static void setCleanInterval(long interval)
interval - the interval in milliseconds. If this is less 1 then the default
value of 60000 (1 minute) will be used.public void clean()
public void put(Object key,
Object data)
public Object get(Object key)
public Iterator keys()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||