|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.axonframework.saga.repository.SagaCache
public class SagaCache
Wrapper around a map of String to Saga that keeps Weak References to the saga instances. As long as any references to a Saga exist, this SagaCache will return that instance when it is looked up using its identifier.
When all references to a Saga are cleared, the garbage collector may clear any unreferenced saga instances from this Cache. When a reference from this Cache is removed, the entry itself may still survive in the cache (albeit empty). To remove any empty entries, use thepurge() method. Empty entries are also cleared when accessed (cache
misses).
Note that the primary purpose of this cache is not to improve performance, but to prevent multiple instances
of the same conceptual saga (i.e. having the same identifier) from being active in the JVM.
| Constructor Summary | |
|---|---|
SagaCache()
Initializes an empty cache. |
|
| Method Summary | |
|---|---|
Saga |
get(String sagaIdentifier)
Retrieves the Saga instance with the given sagaIdentifier, or null if none was found. |
boolean |
isEmpty()
Indicates whether or not this cache is empty. |
void |
purge()
Clears any entries whose saga instances have been cleaned up by the garbage collector. |
Saga |
put(Saga saga)
Puts the given saga in this cache, if no saga with the same identifier already exists. |
int |
size()
Returns an approximation of the number of items in the cache. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SagaCache()
| Method Detail |
|---|
public Saga get(String sagaIdentifier)
sagaIdentifier, or null if none was found.
sagaIdentifier - The identifier of the saga to return
null if none was found.public Saga put(Saga saga)
saga in this cache, if no saga with the same identifier already exists. The return
value provides a reference to the cached saga instance. This may either be the same as saga (in case
the given saga was successfully stored in the cache), or another instance.
Callers of put should always use the returned reference for further processing and regard
the given saga as an unwanted duplicate.
saga - The saga instance to store in the cache
public void purge()
size() of the cache.
public int size()
purge()public boolean isEmpty()
true if the cache is completely empty, false otherwise.purge()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||