|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.cache.support.AbstractDelegatingCache<K,V>
org.springframework.cache.concurrent.ConcurrentCache<K,V>
public class ConcurrentCache<K,V>
Simple Cache implementation based on the JDK 1.5+
java.util.concurrent package. Useful for testing or simple caching scenarios.
| Field Summary |
|---|
| Fields inherited from class org.springframework.cache.support.AbstractDelegatingCache |
|---|
NULL_HOLDER |
| Constructor Summary | |
|---|---|
ConcurrentCache()
|
|
ConcurrentCache(ConcurrentMap<K,V> delegate,
String name)
|
|
ConcurrentCache(String name)
|
|
| Method Summary | |
|---|---|
String |
getName()
Returns the cache name. |
ConcurrentMap<K,V> |
getNativeCache()
Returns the the native, underlying cache provider. |
V |
putIfAbsent(K key,
V value)
If the specified key is not already associated with a value, associate it with the given value. |
boolean |
remove(Object key,
Object value)
Remove entry for key only if currently mapped to given value. |
V |
replace(K key,
V value)
Replace entry for key only if currently mapped to some value. |
boolean |
replace(K key,
V oldValue,
V newValue)
Replace entry for key only if currently mapped to given value. |
| Methods inherited from class org.springframework.cache.support.AbstractDelegatingCache |
|---|
clear, containsKey, filterNull, get, getAllowNullValues, put, remove |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ConcurrentCache()
public ConcurrentCache(String name)
public ConcurrentCache(ConcurrentMap<K,V> delegate,
String name)
| Method Detail |
|---|
public String getName()
Cache
public ConcurrentMap<K,V> getNativeCache()
Cache
public V putIfAbsent(K key,
V value)
Cache
if (!cache.containsKey(key))
return cache.put(key, value);
else
return cache.get(key);
key - key with which the specified value is to be associated.value - value to be associated with the specified key.
public boolean remove(Object key,
Object value)
Cache
if ((cache.containsKey(key) && cache.get(key).equals(value)) {
cache.remove(key);
return true;
}
else
return false;
key - key with which the specified value is associated.value - value associated with the specified key.
public boolean replace(K key,
V oldValue,
V newValue)
Cache
if ((cache.containsKey(key) && cache.get(key).equals(oldValue)) {
cache.put(key, newValue);
return true;
} else return false;
key - key with which the specified value is associated.oldValue - value expected to be associated with the specified key.newValue - value to be associated with the specified key.
public V replace(K key,
V value)
Cache
if ((cache.containsKey(key)) {
return cache.put(key, value);
} else return null;
except that the action is performed atomically.
key - key with which the specified value is associated.value - value to be associated with the specified key.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||