public class SoftMapCache
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static org.apache.commons.logging.Log |
log
logger
|
private java.util.Map |
map |
private java.lang.ref.ReferenceQueue |
refQueue |
Constructor and Description |
---|
SoftMapCache(boolean synched)
Creates a new soft cache.
|
Modifier and Type | Method and Description |
---|---|
private void |
checkReferenceQueue()
Checks the reference queue if any references have been cleared and removes them from the
cache.
|
void |
clear()
Clears the cache.
|
void |
doHouseKeeping()
Triggers some house-keeping, i.e.
|
java.lang.Object |
get(java.lang.Object key)
Returns the value associated with the given key.
|
private java.lang.Object |
getReference(java.lang.Object key,
java.lang.ref.Reference ref) |
void |
put(java.lang.Object key,
java.lang.Object value)
Put a new value in the cache overwriting any existing value with the same key.
|
java.lang.Object |
remove(java.lang.Object key)
Removed the value associated with the given key.
|
private java.lang.ref.Reference |
wrapInReference(java.lang.Object obj,
java.lang.Object key) |
private static org.apache.commons.logging.Log log
private java.util.Map map
private java.lang.ref.ReferenceQueue refQueue
public SoftMapCache(boolean synched)
synched
- true if the Map containing the values should by synchronizedpublic java.lang.Object get(java.lang.Object key)
key
- the keypublic java.lang.Object remove(java.lang.Object key)
key
- the keyprivate java.lang.Object getReference(java.lang.Object key, java.lang.ref.Reference ref)
public void put(java.lang.Object key, java.lang.Object value)
key
- The keyvalue
- the valuepublic void clear()
public void doHouseKeeping()
private java.lang.ref.Reference wrapInReference(java.lang.Object obj, java.lang.Object key)
private void checkReferenceQueue()