|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.ehcache.constructs.EhcacheDecoratorAdapter net.sf.ehcache.constructs.eventual.StronglyConsistentCacheAccessor
public class StronglyConsistentCacheAccessor
StronglyConsistentCacheAccessor is a decorator that accepts distributed caches configured with eventual consistency.
The accessor will then lock for all operations:
Field Summary |
---|
Fields inherited from class net.sf.ehcache.constructs.EhcacheDecoratorAdapter |
---|
underlyingCache |
Constructor Summary | |
---|---|
StronglyConsistentCacheAccessor(Ehcache underlyingCache)
Constructor accepting the cache to be decorated. |
Method Summary | |
---|---|
Element |
get(Object key)
Gets an element from the cache. |
Element |
get(Serializable key)
Gets an element from the cache. |
Map<Object,Element> |
getAll(Collection<?> keys)
Gets all the elements from the cache for the keys provided. |
Map |
getAllWithLoader(Collection keys,
Object loaderArgument)
The getAll method will return, from the cache, a Map of the objects associated with the Collection of keys in argument "keys". |
Element |
getQuiet(Object key)
Gets an element from the cache, without updating Element statistics. |
Element |
getQuiet(Serializable key)
Gets an element from the cache, without updating Element statistics. |
Element |
getWithLoader(Object key,
CacheLoader loader,
Object loaderArgument)
This method will return, from the cache, the object associated with the argument "key". |
void |
put(Element element)
Put an element in the cache. |
void |
put(Element element,
boolean doNotNotifyCacheReplicators)
Put an element in the cache. |
void |
putAll(Collection<Element> elements)
Puts a collection of elements in to the cache. |
Element |
putIfAbsent(Element element)
Put an element in the cache if no element is currently mapped to the elements key. |
Element |
putIfAbsent(Element element,
boolean doNotNotifyCacheReplicators)
Put an element in the cache if no element is currently mapped to the elements key. |
void |
putQuiet(Element element)
Put an element in the cache, without updating statistics, or updating listeners. |
void |
putWithWriter(Element element)
Put an element in the cache writing through a CacheWriter. |
boolean |
remove(Object key)
Removes an Element from the Cache. |
boolean |
remove(Object key,
boolean doNotNotifyCacheReplicators)
Removes an Element from the Cache. |
boolean |
remove(Serializable key)
Removes an Element from the Cache. |
boolean |
remove(Serializable key,
boolean doNotNotifyCacheReplicators)
Removes an Element from the Cache. |
void |
removeAll(Collection<?> keys)
Removes given set of Element from the Cache. |
void |
removeAll(Collection<?> keys,
boolean doNotNotifyCacheReplicators)
Removes all cached items. |
Element |
removeAndReturnElement(Object key)
Removes and returns the element associated with the key |
boolean |
removeElement(Element element)
Remove the Element mapped to the key for the supplied element if the value of the supplied Element compares equal to the value of the cached Element. |
boolean |
removeQuiet(Object key)
Removes an Element from the Cache, without notifying listeners. |
boolean |
removeQuiet(Serializable key)
Removes an Element from the Cache, without notifying listeners. |
boolean |
removeWithWriter(Object key)
Removes an Element from the Cache and any stores it might be in. |
Element |
replace(Element element)
Replace the cached element only if an Element is currently cached for this key |
boolean |
replace(Element old,
Element element)
Replace the cached element only if the current Element is equal to the supplied old Element. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public StronglyConsistentCacheAccessor(Ehcache underlyingCache) throws IllegalArgumentException
underlyingCache
- a clustered cache configured with eventual consistency
IllegalArgumentException
- if the underlying cache is not clustered and has not
eventual consistency.Method Detail |
---|
public Element putIfAbsent(Element element, boolean doNotNotifyCacheReplicators) throws NullPointerException
Ehcache
putIfAbsent
in interface Ehcache
putIfAbsent
in class EhcacheDecoratorAdapter
element
- element to be addeddoNotNotifyCacheReplicators
- whether the put is coming from a doNotNotifyCacheReplicators cache peer, in which case this put should not initiate a
further notification to doNotNotifyCacheReplicators cache peers
NullPointerException
- if the element is null, or has a null keypublic Element putIfAbsent(Element element) throws NullPointerException
EhcacheDecoratorAdapter
putIfAbsent
in interface Ehcache
putIfAbsent
in class EhcacheDecoratorAdapter
element
- element to be added
NullPointerException
- if the element is null, or has a null keypublic boolean replace(Element old, Element element) throws NullPointerException, IllegalArgumentException
EhcacheDecoratorAdapter
replace
in interface Ehcache
replace
in class EhcacheDecoratorAdapter
old
- Element to be test againstelement
- Element to be cached
NullPointerException
- if the either Element is null or has a null key
IllegalArgumentException
- if the two Element keys are non-null but not equalpublic Element replace(Element element) throws NullPointerException
EhcacheDecoratorAdapter
replace
in interface Ehcache
replace
in class EhcacheDecoratorAdapter
element
- Element to be cached
NullPointerException
- if the Element is null or has a null keypublic boolean removeElement(Element element) throws NullPointerException
EhcacheDecoratorAdapter
This is equivalent to
if (elementValueComparator.equals(cache.get(element.getObjectKey()), element)) { return cache.remove(element.getObjectKey()); } else return false;except that the action is performed atomically.
removeElement
in interface Ehcache
removeElement
in class EhcacheDecoratorAdapter
element
- Element to be removed
true
if the value was removed
NullPointerException
- if the element is null, or has a null keyCacheConfiguration.addElementValueComparator(net.sf.ehcache.config.ElementValueComparatorConfiguration)
public void put(Element element, boolean doNotNotifyCacheReplicators) throws IllegalArgumentException, IllegalStateException, CacheException
EhcacheDecoratorAdapter
put
in interface Ehcache
put
in class EhcacheDecoratorAdapter
element
- An object. If Serializable it can fully participate in replication and the DiskStore.doNotNotifyCacheReplicators
- whether the put is coming from a doNotNotifyCacheReplicators cache peer, in which case this put should not initiate a
further notification to doNotNotifyCacheReplicators cache peers
IllegalArgumentException
- if the element is null
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
public void put(Element element) throws IllegalArgumentException, IllegalStateException, CacheException
EhcacheDecoratorAdapter
put
in interface Ehcache
put
in class EhcacheDecoratorAdapter
element
- An object. If Serializable it can fully participate in replication and the DiskStore.
IllegalArgumentException
- if the element is null
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
public void putAll(Collection<Element> elements) throws IllegalArgumentException, IllegalStateException, CacheException
EhcacheDecoratorAdapter
This method will throw a NullPointerException
if a null element or null key is encountered
in the collection, and a partial completion may result (as only some of the elements may have been put).
For each element that is put the registered CacheEventListener
s are notified of a newly put item
(notifyElementPut(...)
)
regardless of whether the individual put is a new put or an update.
putAll
in interface Ehcache
putAll
in class EhcacheDecoratorAdapter
elements
- the collection of elements to be put in the cache.
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
IllegalArgumentException
public void putQuiet(Element element) throws IllegalArgumentException, IllegalStateException, CacheException
EhcacheDecoratorAdapter
Ehcache.getQuiet(java.io.Serializable)
putQuiet
in interface Ehcache
putQuiet
in class EhcacheDecoratorAdapter
element
- An object. If Serializable it can fully participate in replication and the DiskStore.
IllegalArgumentException
- if the element is null
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
public void putWithWriter(Element element) throws IllegalArgumentException, IllegalStateException, CacheException
EhcacheDecoratorAdapter
putWithWriter
in interface Ehcache
putWithWriter
in class EhcacheDecoratorAdapter
element
- An object. If Serializable it can fully participate in replication and the DiskStore.
IllegalArgumentException
- if the element is null
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
- if no CacheWriter was registeredpublic boolean remove(Object key, boolean doNotNotifyCacheReplicators) throws IllegalStateException
EhcacheDecoratorAdapter
Element
from the Cache. This also removes it from any
stores it may be in.
Also notifies the CacheEventListener after the element was removed, but only if an Element
with the key actually existed.
remove
in interface Ehcache
remove
in class EhcacheDecoratorAdapter
doNotNotifyCacheReplicators
- whether the put is coming from a doNotNotifyCacheReplicators cache peer, in which case this put should not initiate a
further notification to doNotNotifyCacheReplicators cache peers
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
public void removeAll(Collection<?> keys) throws IllegalStateException
EhcacheDecoratorAdapter
Element
from the Cache. This also removes them from any
stores it may be in. Throws a NullPointerException if any key in the collection is null
Also notifies the CacheEventListener after the elements were removed.
Notification is sent for every key irrespective of whether the key was present in the cache or not
This operation is partially completed if any element or any key is null
removeAll
in interface Ehcache
removeAll
in class EhcacheDecoratorAdapter
keys
- a collection of keys to operate on
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
public boolean remove(Object key) throws IllegalStateException
EhcacheDecoratorAdapter
Element
from the Cache. This also removes it from any
stores it may be in.
Also notifies the CacheEventListener after the element was removed, but only if an Element
with the key actually existed.
remove
in interface Ehcache
remove
in class EhcacheDecoratorAdapter
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
public void removeAll(Collection<?> keys, boolean doNotNotifyCacheReplicators) throws IllegalStateException
EhcacheDecoratorAdapter
NonstopConfiguration.getBulkOpsTimeoutMultiplyFactor()
times the timeout value in the nonstop config.
removeAll
in interface Ehcache
removeAll
in class EhcacheDecoratorAdapter
doNotNotifyCacheReplicators
- whether the put is coming from a doNotNotifyCacheReplicators cache peer,
in which case this put should not initiate a further notification to doNotNotifyCacheReplicators cache peers
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
public boolean remove(Serializable key, boolean doNotNotifyCacheReplicators) throws IllegalStateException
EhcacheDecoratorAdapter
Element
from the Cache. This also removes it from any
stores it may be in.
Also notifies the CacheEventListener after the element was removed, but only if an Element
with the key actually existed.
remove
in interface Ehcache
remove
in class EhcacheDecoratorAdapter
doNotNotifyCacheReplicators
- whether the put is coming from a doNotNotifyCacheReplicators cache peer, in which case this put should not initiate a
further notification to doNotNotifyCacheReplicators cache peers
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
public boolean remove(Serializable key) throws IllegalStateException
EhcacheDecoratorAdapter
Element
from the Cache. This also removes it from any
stores it may be in.
Also notifies the CacheEventListener after the element was removed.
remove
in interface Ehcache
remove
in class EhcacheDecoratorAdapter
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
public boolean removeQuiet(Object key) throws IllegalStateException
EhcacheDecoratorAdapter
Element
from the Cache, without notifying listeners. This also removes it from any
stores it may be in.
removeQuiet
in interface Ehcache
removeQuiet
in class EhcacheDecoratorAdapter
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
public boolean removeQuiet(Serializable key) throws IllegalStateException
EhcacheDecoratorAdapter
Element
from the Cache, without notifying listeners. This also removes it from any
stores it may be in.
removeQuiet
in interface Ehcache
removeQuiet
in class EhcacheDecoratorAdapter
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
public boolean removeWithWriter(Object key) throws IllegalStateException, CacheException
EhcacheDecoratorAdapter
Element
from the Cache and any stores it might be in. This also removes through
to a CacheWriter. If no CacheWriter has been registered for the cache, then this method throws an exception.
Also notifies the CacheEventListener after the element was removed, but only if an Element
with the key actually existed.
removeWithWriter
in interface Ehcache
removeWithWriter
in class EhcacheDecoratorAdapter
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
- if no CacheWriter was registeredpublic Element removeAndReturnElement(Object key) throws IllegalStateException
EhcacheDecoratorAdapter
removeAndReturnElement
in interface InternalEhcache
removeAndReturnElement
in class EhcacheDecoratorAdapter
key
- the key of the element to operate on
IllegalStateException
public Element get(Object key) throws IllegalStateException, CacheException
EhcacheDecoratorAdapter
Ehcache.getQuiet(Object)
to peek into the Element to see its last access time with get
get
in interface Ehcache
get
in class EhcacheDecoratorAdapter
key
- an Object value
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
Ehcache.isExpired(net.sf.ehcache.Element)
public Map<Object,Element> getAll(Collection<?> keys) throws IllegalStateException, CacheException
EhcacheDecoratorAdapter
Ehcache.getQuiet(Object)
to peek into the Element to see its last access time with get
getAll
in interface Ehcache
getAll
in class EhcacheDecoratorAdapter
keys
- a collection of keys for which value is to be fetched
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
Ehcache.isExpired(net.sf.ehcache.Element)
public Element get(Serializable key) throws IllegalStateException, CacheException
EhcacheDecoratorAdapter
Ehcache.getQuiet(Object)
to peak into the Element to see its last access time with get
get
in interface Ehcache
get
in class EhcacheDecoratorAdapter
key
- a serializable value
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
Ehcache.isExpired(net.sf.ehcache.Element)
public Element getQuiet(Object key) throws IllegalStateException, CacheException
EhcacheDecoratorAdapter
getQuiet
in interface Ehcache
getQuiet
in class EhcacheDecoratorAdapter
key
- a serializable value
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
Ehcache.isExpired(net.sf.ehcache.Element)
public Element getQuiet(Serializable key) throws IllegalStateException, CacheException
EhcacheDecoratorAdapter
getQuiet
in interface Ehcache
getQuiet
in class EhcacheDecoratorAdapter
key
- a serializable value
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
Ehcache.isExpired(net.sf.ehcache.Element)
public Element getWithLoader(Object key, CacheLoader loader, Object loaderArgument) throws CacheException
EhcacheDecoratorAdapter
getWithLoader
in interface Ehcache
getWithLoader
in class EhcacheDecoratorAdapter
key
- key whose associated value is to be returned.loader
- the override loader to use. If null, the cache's default loader will be usedloaderArgument
- an argument to pass to the CacheLoader.
CacheException
public Map getAllWithLoader(Collection keys, Object loaderArgument) throws CacheException
EhcacheDecoratorAdapter
SelfPopulatingCache
getAllWithLoader
in interface Ehcache
getAllWithLoader
in class EhcacheDecoratorAdapter
keys
- a collection of keys to be returned/loadedloaderArgument
- an argument to pass to the CacheLoader.
CacheException
|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |