|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.clerezza.triaxrs.util.SoftConcurrentMap<K,V>
K - V - public class SoftConcurrentMap<K,V>
Concurrent implementation of the SimpleMap interface. This implementation is intend to be used by soft caches, therefore the keys are kept in WeakHashMap, while the value is kept using the SoftReference.
Pay attention that put value always returns the current value and not the original value. It was done to allow the following code pattern:
SoftConcurrentMap<K, V> cache = new SoftConcurrentMap<K, V>(); V cached = cache.get(key); return cached = !null ? cached : cache.put(createValue());
| Constructor Summary | |
|---|---|
SoftConcurrentMap()
Provides the map implementation. |
|
| Method Summary | |
|---|---|
void |
clear()
Removes all mappings from this map (optional operation). |
V |
get(K key)
Returns the value to which this map maps the specified key. |
V |
put(K key,
V val)
Associates the specified value with the specified key in this map. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SoftConcurrentMap()
map - | Method Detail |
|---|
public V get(K key)
SimpleMap
get in interface SimpleMap<K,V>
public V put(K key,
V val)
Unlike the regular Map.put method, this method returns the current value and not the previous value.
Note that a copy on write pattern is used where the existing cache is treated as a read only cache and then it is copied to a new cache.
put in interface SimpleMap<K,V>public void clear()
SimpleMap
clear in interface SimpleMap<K,V>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||