|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.bea.domingo.cache.AbstractBaseCache
de.bea.domingo.cache.WeakCache
public final class WeakCache
Weak Cache.
This implementation of the Cache interface uses
a WeakHashMap to store the keys. The values are stored
as WeakReferences.
Note that this implementation is synchronized. Multiple threads can access this map concurrently.
WeakHashMap,
WeakReference,
Serialized Form| Constructor Summary | |
|---|---|
WeakCache()
Creates a new WeakCache object. |
|
| Method Summary | |
|---|---|
void |
clear()
Removes all mappings from this map (optional operation). |
boolean |
containsKey(java.lang.Object key)
Checks if a given key exists in the cache. |
protected java.util.Map |
createMap()
Creates the map to be used with the cache. |
java.lang.Object |
get(java.lang.Object key)
Returns an object with a given key from the cache. |
java.util.Set |
keySet()
Returns a set view of the keys contained in this cache. |
void |
put(java.lang.Object key,
java.lang.Object value)
Puts an object with a key into the cache. |
java.lang.Object |
remove(java.lang.Object key)
Removes the mapping for this key from this cache if present (optional operation). |
java.util.Collection |
values()
Returns a collection view of the values contained in this cache. |
| Methods inherited from class de.bea.domingo.cache.AbstractBaseCache |
|---|
getMap, size |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WeakCache()
| Method Detail |
|---|
protected java.util.Map createMap()
Concrete classes must implement this method and create a concrete map for the cache.
createMap in class AbstractBaseCacheAbstractBaseCache.createMap()
public void put(java.lang.Object key,
java.lang.Object value)
put in interface Cachekey - the keyvalue - the objectCache.put(java.lang.Object, java.lang.Object),
WeakReference,
Cache.put(java.lang.Object, java.lang.Object)public java.lang.Object get(java.lang.Object key)
get in interface Cachekey - the key
Cache.get(java.lang.Object)public boolean containsKey(java.lang.Object key)
containsKey in interface Cachekey - the key
true if the given key exists in the cache, else
falseCache.containsKey(java.lang.Object)public java.lang.Object remove(java.lang.Object key)
This implementation iterates over entrySet() searching for an entry with the specified key. If such an entry is found, its value is obtained with its getValue operation, the entry is removed from the Collection (and the backing cache) with the iterator's remove operation, and the saved value is returned. If the iteration terminates without finding such an entry, null is returned. Note that this implementation requires linear time in the size of the cache; many implementations will override this method.
remove in interface Cachekey - key whose mapping is to be removed from the cache.
Cache.remove(java.lang.Object)public void clear()
clear in interface CacheCache.clear()public java.util.Set keySet()
keySet in interface CacheCache.keySet()public java.util.Collection values()
values in interface CacheCache.values()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||