|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.dasein.util.ConcurrentCache<K,V>
K - the type for key values stored in the cacheV - the type of objects stored in the cachepublic class ConcurrentCache<K,V>
Caches objects that implement the CachedItem interface and manages their
life cycle. The point of a cache is to act as an automated loader of objects from
some persistent repository on-demand, cache them in memory, and then release them
after they are no longer needed. An application can always rely on the cache to
access the most up-to-date copy of an object and provide shared references to
that object.
Last modified: $Date: 2006/08/15 03:29:28 $
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Constructor Summary | |
|---|---|
ConcurrentCache()
|
|
| Method Summary | |
|---|---|
void |
clear()
Clears out all elements of the cache and starts fresh. |
boolean |
containsKey(Object key)
This method will verify both that the key exists and the value is currently value for the cache. |
boolean |
containsValue(Object val)
Verifies that the specified value is in the cache. |
Set<Map.Entry<K,V>> |
entrySet()
Returns a set of entries in this cache. |
V |
get(Object key)
Retrieves the item associated with the specified key if it is currently valid for the cache. |
V |
getOrLoad(K key,
CacheLoader<V> loader)
Retrieves the value for the specified key. |
boolean |
isEmpty()
|
Set<K> |
keySet()
|
V |
put(K key,
V val)
Places the specified value into the cache. |
void |
putAll(Map<? extends K,? extends V> map)
Places all elements in the specified map into this cache. |
V |
putIfAbsent(K key,
V val)
Conditionally associates the specified value with the specified key if no value currently exists for the key. |
V |
remove(Object key)
Removes the specified object from the cache. |
boolean |
remove(Object key,
Object val)
Removes the specified key only if the current value equals the specified value. |
V |
replace(K key,
V val)
Replaces the specified key only if it has some current value. |
boolean |
replace(K key,
V ov,
V nv)
Replaces the current value of the specified key with the proposed new value only if the current value matches the specified old value. |
int |
size()
|
String |
toString()
|
Collection<V> |
values()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public ConcurrentCache()
| Method Detail |
|---|
public void clear()
clear in interface Map<K,V>public boolean containsKey(Object key)
containsKey in interface Map<K,V>key - the key to test for existence
public boolean containsValue(Object val)
containsValue in interface Map<K,V>val - the desired value
public Set<Map.Entry<K,V>> entrySet()
entrySet in interface Map<K,V>public V get(Object key)
get in interface Map<K,V>key - the key whose item is being sought
public V getOrLoad(K key,
CacheLoader<V> loader)
key - the key being soughtloader - a loader to load a new value if a value is missing
null if no object
exists in the system matching the desired keypublic boolean isEmpty()
isEmpty in interface Map<K,V>
public V put(K key,
V val)
put in interface Map<K,V>key - the key for the item being placed into the cacheval - the item to be cached
public Set<K> keySet()
keySet in interface Map<K,V>public void putAll(Map<? extends K,? extends V> map)
putAll in interface Map<K,V>map - the map to store in this cache.
public V putIfAbsent(K key,
V val)
putIfAbsent in interface ConcurrentMap<K,V>key - the key for which a value is to be storedval - the proposed new value
public V remove(Object key)
remove in interface Map<K,V>key - the key to be removed from the cache
public boolean remove(Object key,
Object val)
remove in interface ConcurrentMap<K,V>key - the key to be removedval - the value that must be matched by the current value for this key
public V replace(K key,
V val)
replace in interface ConcurrentMap<K,V>key - the key to replaceval - the new value
public boolean replace(K key,
V ov,
V nv)
replace in interface ConcurrentMap<K,V>key - the key whose value should be replacedov - the old value that should match the current value in the cachenv - the new value to put in the cache
public int size()
size in interface Map<K,V>public Collection<V> values()
values in interface Map<K,V>public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||