|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.axonframework.cache.WeakReferenceCache
public class WeakReferenceCache
Cache implementation that keeps values in the cache until the garbage collector has removed them. Unlike the WeakHashMap, which uses weak references on the keys, this Cache uses weak references on the values.
Values are Weakly referenced, which means they are not eligible for removal as long as any other references to the value exist. Items expire once the garbage collector has removed them. Some time after they have been removed, the entry listeners are being notified thereof. Note that notification are emitted when the cache is being accessed (either for reading or writing). If the cache is not being accessed for a longer period of time, it may occur that listeners are not notified.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.axonframework.cache.Cache |
|---|
Cache.EntryListener, Cache.EntryListenerAdapter |
| Constructor Summary | |
|---|---|
WeakReferenceCache()
|
|
| Method Summary | ||
|---|---|---|
|
containsKey(K key)
Indicates whether there is an item stored under given key. |
|
|
get(K key)
Returns an item from the cache, or null if no item was stored under that key |
|
|
put(K key,
V value)
Stores the given value in the cache, under given key. |
|
|
putIfAbsent(K key,
V value)
Stores the given value in the cache, under given key, if no element is yet available
under that key. |
|
void |
registerCacheEntryListener(Cache.EntryListener entryListener)
Registers the given cacheEntryListener to listen for Cache changes. |
|
|
remove(K key)
Removes the entry stored under given key. |
|
void |
unregisterCacheEntryListener(Cache.EntryListener entryListener)
Unregisters the previously registered cacheEntryListener. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WeakReferenceCache()
| Method Detail |
|---|
public void registerCacheEntryListener(Cache.EntryListener entryListener)
CachecacheEntryListener to listen for Cache changes.
registerCacheEntryListener in interface CacheentryListener - The listener to registerpublic void unregisterCacheEntryListener(Cache.EntryListener entryListener)
CachecacheEntryListener.
unregisterCacheEntryListener in interface CacheentryListener - The listener to unregisterpublic <K,V> V get(K key)
Cachenull if no item was stored under that key
get in interface CacheK - The type of key usedV - The type of value storedkey - The key under which the item was cached
public <K,V> void put(K key,
V value)
Cachevalue in the cache, under given key. If an item already exists,
it is updated with the new value.
put in interface CacheK - The type of key usedV - The type of value storedkey - The key under which to store the itemvalue - The item to cache
public <K,V> boolean putIfAbsent(K key,
V value)
Cachevalue in the cache, under given key, if no element is yet available
under that key. This operation is performed atomically.
putIfAbsent in interface CacheK - The type of key usedV - The type of value storedkey - The key under which to store the itemvalue - The item to cache
true if no value was previously assigned to the key, false otherwise.public <K> boolean remove(K key)
Cachekey. If no such entry exists, nothing happens.
remove in interface CacheK - The type of key usedkey - The key under which the item was stored
true if a value was previously assigned to the key and has been removed, false
otherwise.public <K> boolean containsKey(K key)
Cachekey.
containsKey in interface CacheK - The type of keykey - The key to check
true if an item is available under that key, false otherwise.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||