- java.lang.Object
-
- util.misc.SoftReferenceCache<T,K>
-
public class SoftReferenceCache<T,K> extends java.lang.Object
This class implements a Cache using soft references. As soon as the garbage collector tries to remove an object, it gets removed from the cache.- Since:
- 2.7
-
-
Constructor Summary
Constructors Constructor Description SoftReferenceCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanUp()
Cleanup the cache.void
clear()
Clear the cacheboolean
containsKey(T key)
Checks if the cache contains a specific keyK
get(T key)
Get the value from the Cachevoid
put(T key, K object)
Put a object into the cachevoid
remove(T key)
Remove item from cache
-
-
-
Method Detail
-
get
public K get(T key)
Get the value from the Cache- Parameters:
key
- get value for this key- Returns:
- The referenced Object.
-
put
public void put(T key, K object)
Put a object into the cache- Parameters:
key
- key for this objectobject
- object to store in the cache
-
remove
public void remove(T key)
Remove item from cache- Parameters:
key
- remove item that references this key
-
clear
public void clear()
Clear the cache
-
cleanUp
public void cleanUp()
Cleanup the cache. Every garbage collected item must be removed
-
containsKey
public boolean containsKey(T key)
Checks if the cache contains a specific key- Parameters:
key
- search for this key- Returns:
true
if this cache contains this key
-
-