|
ehcache | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.ehcache.constructs.EhcacheDecoratorAdapter
public class EhcacheDecoratorAdapter
Adapter class for Ehcache interface decorators. Implements all method in Ehcache by delegating all calls to the decorated
Ehcache. This class is provided as a convenience for easily creating Ehcache decorators by extending this class and
overriding only the methods of interest.
| Field Summary | |
|---|---|
protected Ehcache |
underlyingCache
The decorated Ehcache, has protected visibility so that sub-classes can have access to it. |
| Constructor Summary | |
|---|---|
EhcacheDecoratorAdapter(Ehcache underlyingCache)
Constructor accepting the cache to be decorated |
|
| Method Summary | ||
|---|---|---|
void |
acquireReadLockOnKey(java.lang.Object key)
Acquires the proper read lock for a given cache key |
|
void |
acquireWriteLockOnKey(java.lang.Object key)
Acquires the proper write lock for a given cache key |
|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a PropertyChangeListener. |
|
void |
bootstrap()
Bootstrap command. |
|
long |
calculateInMemorySize()
Gets the size of the memory store for this cache Warning: This method can be very expensive to run. |
|
long |
calculateOffHeapSize()
Gets the size of the off-heap store for this cache |
|
void |
clearStatistics()
Resets statistics counters back to 0. |
|
java.lang.Object |
clone()
Clones a cache. |
|
Query |
createQuery()
Create a new query builder for this cache |
|
void |
disableDynamicFeatures()
Disables dynamic configuration and disable/enable for this cache. |
|
void |
dispose()
Flushes all cache items from memory to auxilliary caches and close the auxilliary caches. |
|
void |
evictExpiredElements()
Causes all elements stored in the Cache to be synchronously checked for expiry, and if expired, evicted. |
|
void |
flush()
Flushes all cache items from memory to the disk store, and from the DiskStore to disk. |
|
Element |
get(java.lang.Object key)
Gets an element from the cache. |
|
Element |
get(java.io.Serializable key)
Gets an element from the cache. |
|
java.util.Map |
getAllWithLoader(java.util.Collection keys,
java.lang.Object loaderArgument)
The getAll method will return, from the cache, a Map of the objects associated with the Collection of keys in argument "keys". |
|
float |
getAverageGetTime()
The average get time in ms. |
|
long |
getAverageSearchTime()
Get the average search execution time (in millis) for searches that have completed in the last sample period |
|
BootstrapCacheLoader |
getBootstrapCacheLoader()
Accessor for the BootstrapCacheLoader associated with this cache. |
|
CacheConfiguration |
getCacheConfiguration()
Gets the cache configuration this cache was created with. |
|
RegisteredEventListeners |
getCacheEventNotificationService()
Use this to access the service in order to register and unregister listeners |
|
CacheExceptionHandler |
getCacheExceptionHandler()
Sets an ExceptionHandler on the Cache. |
|
CacheManager |
getCacheManager()
Gets the CacheManager managing this cache. |
|
int |
getDiskStoreSize()
Returns the number of elements in the disk store. |
|
java.lang.String |
getGuid()
The GUID for this cache instance can be used to determine whether two cache instance references are pointing to the same cache. |
|
java.lang.Object |
getInternalContext()
This should not be used return some internal context (generally will be null) |
|
java.util.List |
getKeys()
Returns a list of all elements in the cache, whether or not they are expired. |
|
java.util.List |
getKeysNoDuplicateCheck()
Returns a list of all elements in the cache, whether or not they are expired. |
|
java.util.List |
getKeysWithExpiryCheck()
Returns a list of all elements in the cache. |
|
LiveCacheStatistics |
getLiveCacheStatistics()
This is different from Ehcache.getStatistics() in the way that values
returned from LiveCacheStatistics will reflect the current state
of the cache (and not a snapshot of the cache when the api's were called
like Ehcache.getStatistics()) |
|
long |
getMemoryStoreSize()
Returns the number of elements in the memory store. |
|
java.lang.String |
getName()
Gets the cache name. |
|
long |
getOffHeapStoreSize()
Returns the number of elements in the off-heap store. |
|
Element |
getQuiet(java.lang.Object key)
Gets an element from the cache, without updating Element statistics. |
|
Element |
getQuiet(java.io.Serializable key)
Gets an element from the cache, without updating Element statistics. |
|
java.util.List<CacheExtension> |
getRegisteredCacheExtensions()
|
|
java.util.List<CacheLoader> |
getRegisteredCacheLoaders()
|
|
CacheWriter |
getRegisteredCacheWriter()
Retrieves the CacheWriter that was registered for this cache. |
|
SampledCacheStatistics |
getSampledCacheStatistics()
Returns sampled statistics for this cache. |
|
|
getSearchAttribute(java.lang.String attributeName)
Retrieve the given named search attribute |
|
long |
getSearchesPerSecond()
Get the number of search executions that have completed in the last second |
|
int |
getSize()
Gets the size of the cache. |
|
int |
getSizeBasedOnAccuracy(int statisticsAccuracy)
Accurately measuring statistics can be expensive. |
|
Statistics |
getStatistics()
Gets an immutable Statistics object representing the Cache statistics at the time. |
|
int |
getStatisticsAccuracy()
Accurately measuring statistics can be expensive. |
|
Status |
getStatus()
Gets the status attribute of the Cache. |
|
Element |
getWithLoader(java.lang.Object key,
CacheLoader loader,
java.lang.Object loaderArgument)
This method will return, from the cache, the object associated with the argument "key". |
|
CacheWriterManager |
getWriterManager()
Obtain the writer manager that's used by this cache instance. |
|
void |
initialise()
Newly created caches do not have a MemoryStore or a DiskStore. |
|
boolean |
isClusterBulkLoadEnabled()
Returns true if at least one node in the cluster is in bulk-load mode. |
|
boolean |
isClusterCoherent()
Deprecated. Use isClusterBulkLoadEnabled() instead |
|
boolean |
isDisabled()
Whether this cache is disabled. |
|
boolean |
isElementInMemory(java.lang.Object key)
Whether an Element is stored in the cache in Memory, indicating a very low cost of retrieval. |
|
boolean |
isElementInMemory(java.io.Serializable key)
Whether an Element is stored in the cache in Memory, indicating a very low cost of retrieval. |
|
boolean |
isElementOnDisk(java.lang.Object key)
Whether an Element is stored in the cache on Disk, indicating a higher cost of retrieval. |
|
boolean |
isElementOnDisk(java.io.Serializable key)
Whether an Element is stored in the cache on Disk, indicating a higher cost of retrieval. |
|
boolean |
isExpired(Element element)
Checks whether this cache element has expired. |
|
boolean |
isKeyInCache(java.lang.Object key)
An inexpensive check to see if the key exists in the cache. |
|
boolean |
isNodeBulkLoadEnabled()
Returns true if the current node is in bulk-load mode. |
|
boolean |
isNodeCoherent()
Deprecated. Use isNodeBulkLoadEnabled() instead |
|
boolean |
isReadLockedByCurrentThread(java.lang.Object key)
Returns true if a read lock for the key is held by the current thread |
|
boolean |
isSampledStatisticsEnabled()
Returns if sampled statistics collection is enabled or disabled |
|
boolean |
isSearchable()
Is this cache searchable? |
|
boolean |
isStatisticsEnabled()
Returns true if statistics collection is enabled |
|
boolean |
isValueInCache(java.lang.Object value)
An extremely expensive check to see if the value exists in the cache. |
|
boolean |
isWriteLockedByCurrentThread(java.lang.Object key)
Returns true if a write lock for the key is held by the current thread |
|
void |
load(java.lang.Object key)
The load method provides a means to "pre load" the cache. |
|
void |
loadAll(java.util.Collection keys,
java.lang.Object argument)
The loadAll method provides a means to "pre load" objects into the cache. |
|
void |
put(Element element)
Put an element in the cache. |
|
void |
put(Element element,
boolean doNotNotifyCacheReplicators)
Put an element in the cache. |
|
Element |
putIfAbsent(Element element)
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. |
|
void |
registerCacheExtension(CacheExtension cacheExtension)
Register a CacheExtension with the cache. |
|
void |
registerCacheLoader(CacheLoader cacheLoader)
Register a CacheLoader with the cache. |
|
void |
registerCacheUsageListener(CacheUsageListener cacheUsageListener)
Registers a CacheUsageListener which will be notified of the
cache
usage. |
|
void |
registerCacheWriter(CacheWriter cacheWriter)
Register the CacheWriter for this cache. |
|
void |
releaseReadLockOnKey(java.lang.Object key)
Release a held read lock for the passed in key |
|
void |
releaseWriteLockOnKey(java.lang.Object key)
Release a held write lock for the passed in key |
|
boolean |
remove(java.lang.Object key)
Removes an Element from the Cache. |
|
boolean |
remove(java.lang.Object key,
boolean doNotNotifyCacheReplicators)
Removes an Element from the Cache. |
|
boolean |
remove(java.io.Serializable key)
Removes an Element from the Cache. |
|
boolean |
remove(java.io.Serializable key,
boolean doNotNotifyCacheReplicators)
Removes an Element from the Cache. |
|
void |
removeAll()
Removes all cached items. |
|
void |
removeAll(boolean doNotNotifyCacheReplicators)
Removes all cached items. |
|
void |
removeCacheUsageListener(CacheUsageListener cacheUsageListener)
Remove an already registered CacheUsageListener, if any. |
|
boolean |
removeElement(Element element)
Remove the Element mapped to the key for the supplied element if the value of the supplied Element is equal to the value of the cached Element. |
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a PropertyChangeListener. |
|
boolean |
removeQuiet(java.lang.Object key)
Removes an Element from the Cache, without notifying listeners. |
|
boolean |
removeQuiet(java.io.Serializable key)
Removes an Element from the Cache, without notifying listeners. |
|
boolean |
removeWithWriter(java.lang.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. |
|
void |
setBootstrapCacheLoader(BootstrapCacheLoader bootstrapCacheLoader)
Sets the bootstrap cache loader. |
|
void |
setCacheExceptionHandler(CacheExceptionHandler cacheExceptionHandler)
Sets an ExceptionHandler on the Cache. |
|
void |
setCacheManager(CacheManager cacheManager)
Sets the CacheManager |
|
void |
setDisabled(boolean disabled)
Disables or enables this cache. |
|
void |
setDiskStorePath(java.lang.String diskStorePath)
DiskStore paths can conflict between CacheManager instances. |
|
void |
setName(java.lang.String name)
Sets the cache name which will name. |
|
void |
setNodeBulkLoadEnabled(boolean enabledBulkLoad)
Enable/disable bulk-load mode in this node for this cache. |
|
void |
setNodeCoherent(boolean coherent)
Deprecated. Use setNodeBulkLoadEnabled(boolean) instead |
|
void |
setSampledStatisticsEnabled(boolean enableStatistics)
Enable/disable sampled statistics collection. |
|
void |
setStatisticsAccuracy(int statisticsAccuracy)
Sets the statistics accuracy. |
|
void |
setStatisticsEnabled(boolean enableStatistics)
Enable/disable statistics collection. |
|
void |
setTransactionManagerLookup(TransactionManagerLookup transactionManagerLookup)
This class is used to access the transaction manager used during XA. |
|
java.lang.String |
toString()
Returns a String representation of Cache. |
|
boolean |
tryReadLockOnKey(java.lang.Object key,
long timeout)
Try to get a read lock on a given key. |
|
boolean |
tryWriteLockOnKey(java.lang.Object key,
long timeout)
Try to get a write lock on a given key. |
|
void |
unregisterCacheExtension(CacheExtension cacheExtension)
Unregister a CacheExtension with the cache. |
|
void |
unregisterCacheLoader(CacheLoader cacheLoader)
Unregister a CacheLoader with the cache. |
|
void |
unregisterCacheWriter()
Unregister the CacheWriter from the cache. |
|
void |
waitUntilClusterBulkLoadComplete()
This method waits until all the connected nodes have disabled bulk-load. |
|
void |
waitUntilClusterCoherent()
Deprecated. Use waitUntilClusterBulkLoadComplete() instead |
|
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected final Ehcache underlyingCache
Ehcache, has protected visibility so that sub-classes can have access to it.
| Constructor Detail |
|---|
public EhcacheDecoratorAdapter(Ehcache underlyingCache)
underlyingCache - | Method Detail |
|---|
public Element get(java.lang.Object key)
throws java.lang.IllegalStateException,
CacheException
Ehcache.getQuiet(Object) to peak into the Element to see its last access time with get
get in interface Ehcachekey - an Object value
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
CacheExceptionEhcache.isExpired(net.sf.ehcache.Element)
public Element get(java.io.Serializable key)
throws java.lang.IllegalStateException,
CacheException
Ehcache.getQuiet(Object) to peak into the Element to see its last access time with get
get in interface Ehcachekey - a serializable value
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
CacheExceptionEhcache.isExpired(net.sf.ehcache.Element)
public Element getQuiet(java.lang.Object key)
throws java.lang.IllegalStateException,
CacheException
getQuiet in interface Ehcachekey - a serializable value
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
CacheExceptionEhcache.isExpired(net.sf.ehcache.Element)
public Element getQuiet(java.io.Serializable key)
throws java.lang.IllegalStateException,
CacheException
getQuiet in interface Ehcachekey - a serializable value
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
CacheExceptionEhcache.isExpired(net.sf.ehcache.Element)
public void put(Element element,
boolean doNotNotifyCacheReplicators)
throws java.lang.IllegalArgumentException,
java.lang.IllegalStateException,
CacheException
put in interface Ehcacheelement - 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
java.lang.IllegalArgumentException - if the element is null
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
CacheException
public void put(Element element)
throws java.lang.IllegalArgumentException,
java.lang.IllegalStateException,
CacheException
put in interface Ehcacheelement - An object. If Serializable it can fully participate in replication and the DiskStore.
java.lang.IllegalArgumentException - if the element is null
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
CacheException
public void putQuiet(Element element)
throws java.lang.IllegalArgumentException,
java.lang.IllegalStateException,
CacheException
Ehcache.getQuiet(java.io.Serializable)
putQuiet in interface Ehcacheelement - An object. If Serializable it can fully participate in replication and the DiskStore.
java.lang.IllegalArgumentException - if the element is null
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
CacheException
public void putWithWriter(Element element)
throws java.lang.IllegalArgumentException,
java.lang.IllegalStateException,
CacheException
putWithWriter in interface Ehcacheelement - An object. If Serializable it can fully participate in replication and the DiskStore.
java.lang.IllegalArgumentException - if the element is null
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
CacheException - if no CacheWriter was registered
public boolean remove(java.lang.Object key,
boolean doNotNotifyCacheReplicators)
throws java.lang.IllegalStateException
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 EhcachedoNotNotifyCacheReplicators - 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
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
public boolean remove(java.lang.Object key)
throws java.lang.IllegalStateException
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 Ehcachejava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
public boolean remove(java.io.Serializable key,
boolean doNotNotifyCacheReplicators)
throws java.lang.IllegalStateException
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 EhcachedoNotNotifyCacheReplicators - 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
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
public boolean remove(java.io.Serializable key)
throws java.lang.IllegalStateException
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 Ehcachejava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
public void removeAll()
throws java.lang.IllegalStateException,
CacheException
NonstopConfiguration.getBulkOpsTimeoutMultiplyFactor() times the timeout value in the nonstop config.
removeAll in interface Ehcachejava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
CacheException
public void removeAll(boolean doNotNotifyCacheReplicators)
throws java.lang.IllegalStateException,
CacheException
NonstopConfiguration.getBulkOpsTimeoutMultiplyFactor() times the timeout value in the nonstop config.
removeAll in interface EhcachedoNotNotifyCacheReplicators - 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
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
CacheExceptionpublic void bootstrap()
bootstrap in interface Ehcache
public long calculateInMemorySize()
throws java.lang.IllegalStateException,
CacheException
calculateInMemorySize in interface Ehcachejava.lang.IllegalStateException
CacheException
public long calculateOffHeapSize()
throws java.lang.IllegalStateException,
CacheException
calculateOffHeapSize in interface Ehcachejava.lang.IllegalStateException
CacheExceptionpublic void clearStatistics()
clearStatistics in interface Ehcachepublic void disableDynamicFeatures()
This is a one time operation. Once an Ehcache instance has had its dynamic operations disabled they cannot be re-enabled.
disableDynamicFeatures in interface Ehcache
public void dispose()
throws java.lang.IllegalStateException
dispose in interface Ehcachejava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVEpublic void evictExpiredElements()
evictExpiredElements in interface Ehcache
public void flush()
throws java.lang.IllegalStateException,
CacheException
flush in interface Ehcachejava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
CacheException
public Element getWithLoader(java.lang.Object key,
CacheLoader loader,
java.lang.Object loaderArgument)
throws CacheException
getWithLoader in interface Ehcachekey - 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 java.util.Map getAllWithLoader(java.util.Collection keys,
java.lang.Object loaderArgument)
throws CacheException
SelfPopulatingCache
getAllWithLoader in interface Ehcachekeys - a collection of keys to be returned/loadedloaderArgument - an argument to pass to the CacheLoader.
CacheExceptionpublic void registerCacheLoader(CacheLoader cacheLoader)
CacheLoader with the cache. It will then be tied into the cache lifecycle.
If the CacheLoader is not initialised, initialise it.
registerCacheLoader in interface EhcachecacheLoader - A Cache Loader to registerpublic void unregisterCacheLoader(CacheLoader cacheLoader)
CacheLoader with the cache. It will then be detached from the cache lifecycle.
unregisterCacheLoader in interface EhcachecacheLoader - A Cache Loader to unregister
public void load(java.lang.Object key)
throws CacheException
SelfPopulatingCache
load in interface Ehcachekey - key whose associated value to be loaded using the associated cacheloader if this cache doesn't contain it.
CacheException
public void loadAll(java.util.Collection keys,
java.lang.Object argument)
throws CacheException
SelfPopulatingCache
loadAll in interface EhcacheCacheExceptionpublic float getAverageGetTime()
getAverageGetTime in interface Ehcachepublic BootstrapCacheLoader getBootstrapCacheLoader()
getBootstrapCacheLoader in interface Ehcachepublic CacheConfiguration getCacheConfiguration()
getCacheConfiguration in interface Ehcachepublic RegisteredEventListeners getCacheEventNotificationService()
getCacheEventNotificationService in interface Ehcachepublic CacheExceptionHandler getCacheExceptionHandler()
getCacheExceptionHandler in interface Ehcachepublic CacheManager getCacheManager()
getCacheManager in interface Ehcache
public long getOffHeapStoreSize()
throws java.lang.IllegalStateException
getOffHeapStoreSize in interface Ehcachejava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
public int getDiskStoreSize()
throws java.lang.IllegalStateException
getDiskStoreSize in interface Ehcachejava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVEpublic java.lang.String getGuid()
getGuid in interface Ehcachepublic java.lang.Object getInternalContext()
getInternalContext in interface Ehcache
public java.util.List getKeys()
throws java.lang.IllegalStateException,
CacheException
getKeys in interface EhcacheObject keys
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
CacheException
public java.util.List getKeysNoDuplicateCheck()
throws java.lang.IllegalStateException
getKeysNoDuplicateCheck in interface EhcacheObject keys
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
public java.util.List getKeysWithExpiryCheck()
throws java.lang.IllegalStateException,
CacheException
Ehcache.getKeys()
, which is synchronised, and which takes 8ms per 1000 entries. This way
cache liveness is preserved, even if this method is very slow to return.
Consider whether your usage requires checking for expired keys. Because
this method takes so long, depending on cache settings, the list could be
quite out of date by the time you get it.
getKeysWithExpiryCheck in interface EhcacheObject keys
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
CacheException
public LiveCacheStatistics getLiveCacheStatistics()
throws java.lang.IllegalStateException
Ehcache.getStatistics() in the way that values
returned from LiveCacheStatistics will reflect the current state
of the cache (and not a snapshot of the cache when the api's were called
like Ehcache.getStatistics())
getLiveCacheStatistics in interface EhcacheLiveCacheStatistics associated with this cache
java.lang.IllegalStateException
public long getMemoryStoreSize()
throws java.lang.IllegalStateException
getMemoryStoreSize in interface Ehcachejava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVEpublic java.lang.String getName()
getName in interface Ehcachepublic java.util.List<CacheExtension> getRegisteredCacheExtensions()
getRegisteredCacheExtensions in interface Ehcachepublic java.util.List<CacheLoader> getRegisteredCacheLoaders()
getRegisteredCacheLoaders in interface Ehcachepublic CacheWriter getRegisteredCacheWriter()
CacheWriter that was registered for this cache.
getRegisteredCacheWriter in interface EhcacheCacheWriter; or null if none was registered beforepublic SampledCacheStatistics getSampledCacheStatistics()
getSampledCacheStatistics in interface Ehcache
public int getSize()
throws java.lang.IllegalStateException,
CacheException
Elements in the MemoryStore plus
the number of Elements in the DiskStore.
This number is the actual number of elements, including expired elements that have
not been removed.
Expired elements are removed from the the memory store when
getting an expired element, or when attempting to spool an expired element to
disk.
Expired elements are removed from the disk store when getting an expired element,
or when the expiry thread runs, which is once every five minutes.
To get an exact size, which would exclude expired elements, use Ehcache.getKeysWithExpiryCheck().size(),
although see that method for the approximate time that would take.
To get a very fast result, use Ehcache.getKeysNoDuplicateCheck().size(). If the disk store
is being used, there will be some duplicates.
Note:getSize() is a very expensive operation in off-heap, disk and Terracotta implementations.
getSize in interface Ehcachejava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
CacheException
public int getSizeBasedOnAccuracy(int statisticsAccuracy)
throws java.lang.IllegalArgumentException,
java.lang.IllegalStateException,
CacheException
getSizeBasedOnAccuracy in interface EhcachestatisticsAccuracy - one of Statistics.STATISTICS_ACCURACY_BEST_EFFORT,
Statistics.STATISTICS_ACCURACY_GUARANTEED,
Statistics.STATISTICS_ACCURACY_NONE
java.lang.IllegalArgumentException - if the statisticsAccuracy is not one of the above
java.lang.IllegalStateException - if the cache is not
Status.STATUS_ALIVE
CacheException
public Statistics getStatistics()
throws java.lang.IllegalStateException
Statistics.STATISTICS_ACCURACY_BEST_EFFORT.
The size is the number of Elements in the MemoryStore plus
the number of Elements in the DiskStore.
This number is the actual number of elements, including expired elements that have
not been removed. Any duplicates between stores are accounted for.
Expired elements are removed from the the memory store when
getting an expired element, or when attempting to spool an expired element to
disk.
Expired elements are removed from the disk store when getting an expired element,
or when the expiry thread runs, which is once every five minutes.
Statistics.STATISTICS_ACCURACY_GUARANTEED.
This method accounts for elements which might be expired or duplicated between stores. It take approximately
200ms per 1000 elements to execute.
Statistics.STATISTICS_ACCURACY_NONE.
The number given may contain expired elements. In addition if the DiskStore is used it may contain some double
counting of elements. It takes 6ms for 1000 elements to execute. Time to execute is O(log n). 50,000 elements take
36ms.
getStatistics in interface Ehcachejava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVEpublic int getStatisticsAccuracy()
getStatisticsAccuracy in interface EhcacheStatistics.STATISTICS_ACCURACY_BEST_EFFORT, Statistics.STATISTICS_ACCURACY_GUARANTEED, Statistics.STATISTICS_ACCURACY_NONEpublic Status getStatus()
getStatus in interface Ehcachepublic CacheWriterManager getWriterManager()
getWriterManager in interface Ehcachepublic void initialise()
MemoryStore or a DiskStore.
This method creates those and makes the cache ready to accept elements
initialise in interface Ehcache@Deprecated public boolean isClusterCoherent()
isClusterBulkLoadEnabled() instead
isClusterCoherent in interface Ehcachepublic boolean isDisabled()
Ehcache.setDisabled(boolean) method.
isDisabled in interface Ehcachepublic boolean isElementInMemory(java.lang.Object key)
Since no assertions are made about the state of the Element it is possible that the Element is expired, but this method still returns true.
isElementInMemory in interface Ehcachepublic boolean isElementInMemory(java.io.Serializable key)
Since no assertions are made about the state of the Element it is possible that the Element is expired, but this method still returns true.
isElementInMemory in interface Ehcachepublic boolean isElementOnDisk(java.lang.Object key)
Since no assertions are made about the state of the Element it is possible that the Element is expired, but this method still returns true.
isElementOnDisk in interface Ehcachepublic boolean isElementOnDisk(java.io.Serializable key)
Since no assertions are made about the state of the Element it is possible that the Element is expired, but this method still returns true.
isElementOnDisk in interface Ehcache
public boolean isExpired(Element element)
throws java.lang.IllegalStateException,
java.lang.NullPointerException
isExpired in interface Ehcacheelement - the element to check
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
java.lang.NullPointerException - if the element is nullpublic boolean isKeyInCache(java.lang.Object key)
Since no assertions are made about the state of the Element it is possible that the Element is expired, but this method still returns true.
isKeyInCache in interface Ehcachekey - the key to check for
@Deprecated public boolean isNodeCoherent()
isNodeBulkLoadEnabled() instead
isNodeCoherent in interface Ehcachepublic boolean isSampledStatisticsEnabled()
isSampledStatisticsEnabled in interface Ehcachepublic boolean isStatisticsEnabled()
isStatisticsEnabled in interface Ehcachepublic boolean isValueInCache(java.lang.Object value)
isValueInCache in interface Ehcachevalue - to check for
public void registerCacheExtension(CacheExtension cacheExtension)
CacheExtension with the cache. It will then be tied into the cache lifecycle.
If the CacheExtension is not initialised, initialise it.
registerCacheExtension in interface Ehcache
public void registerCacheUsageListener(CacheUsageListener cacheUsageListener)
throws java.lang.IllegalStateException
CacheUsageListener which will be notified of the
cache
usage.
Implementations of CacheUsageListener should override the
Object.equals(Object) and Object.hashCode() methods as it is used for
equality check
registerCacheUsageListener in interface Ehcachejava.lang.IllegalStateExceptionpublic void registerCacheWriter(CacheWriter cacheWriter)
CacheWriter for this cache. It will then be tied into the cache lifecycle.
If the CacheWriter is not initialised, initialise it.
registerCacheWriter in interface EhcachecacheWriter - A CacheWriter to register
public void removeCacheUsageListener(CacheUsageListener cacheUsageListener)
throws java.lang.IllegalStateException
CacheUsageListener, if any.
Depends on the Object.equals(Object) method.
removeCacheUsageListener in interface Ehcachejava.lang.IllegalStateException
public boolean removeQuiet(java.lang.Object key)
throws java.lang.IllegalStateException
Element from the Cache, without notifying listeners. This also removes it from any
stores it may be in.
removeQuiet in interface Ehcachejava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
public boolean removeQuiet(java.io.Serializable key)
throws java.lang.IllegalStateException
Element from the Cache, without notifying listeners. This also removes it from any
stores it may be in.
removeQuiet in interface Ehcachejava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
public boolean removeWithWriter(java.lang.Object key)
throws java.lang.IllegalStateException,
CacheException
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 Ehcachejava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
CacheException - if no CacheWriter was registered
public void setBootstrapCacheLoader(BootstrapCacheLoader bootstrapCacheLoader)
throws CacheException
setBootstrapCacheLoader in interface EhcachebootstrapCacheLoader - the loader to be used
CacheException - if this method is called after the cache is initializedpublic void setCacheExceptionHandler(CacheExceptionHandler cacheExceptionHandler)
setCacheExceptionHandler in interface Ehcachepublic void setCacheManager(CacheManager cacheManager)
setCacheManager in interface EhcachecacheManager - the CacheManager for this cache to use.public void setDisabled(boolean disabled)
setDisabled in interface Ehcachedisabled - true if you wish to disable, false to enableEhcache.isDisabled()
public void setDiskStorePath(java.lang.String diskStorePath)
throws CacheException
setDiskStorePath in interface EhcachediskStorePath - the new path to be used.
CacheException - if this method is called after the cache is initializedpublic void setName(java.lang.String name)
setName in interface Ehcachename - the name of the cache. Should not be null.
@Deprecated
public void setNodeCoherent(boolean coherent)
throws java.lang.UnsupportedOperationException
setNodeBulkLoadEnabled(boolean) instead
setNodeCoherent(true) when the cache is already in coherent mode or
calling setNodeCoherent(false) when already in incoherent mode will be a no-op.
It applies to coherent clustering mechanisms only e.g. Terracotta
When using Terracotta clustered caches with nonstop enabled, the timeout used by this method is
NonstopConfiguration.getBulkOpsTimeoutMultiplyFactor() times the timeout value in the config.
setNodeCoherent in interface Ehcachecoherent - true transitions to coherent mode, false to incoherent mode
java.lang.UnsupportedOperationException - if this cache does not support coherence, like RMI replicationpublic void setSampledStatisticsEnabled(boolean enableStatistics)
setSampledStatisticsEnabled in interface Ehcachepublic void setStatisticsAccuracy(int statisticsAccuracy)
setStatisticsAccuracy in interface EhcachestatisticsAccuracy - one of Statistics.STATISTICS_ACCURACY_BEST_EFFORT, Statistics.STATISTICS_ACCURACY_GUARANTEED, Statistics.STATISTICS_ACCURACY_NONEpublic void setStatisticsEnabled(boolean enableStatistics)
Ehcache.setSampledStatisticsEnabled(boolean) with
parameter true.
Disabling statistics also disables the sampled statistics collection if
it is enabled
setStatisticsEnabled in interface Ehcachepublic void setTransactionManagerLookup(TransactionManagerLookup transactionManagerLookup)
setTransactionManagerLookup in interface Ehcachepublic void unregisterCacheExtension(CacheExtension cacheExtension)
CacheExtension with the cache. It will then be detached from the cache lifecycle.
unregisterCacheExtension in interface Ehcachepublic void unregisterCacheWriter()
CacheWriter from the cache. It will then be detached from the cache lifecycle.
If not CacheWriter was registered beforehand this operation has no effect.
unregisterCacheWriter in interface Ehcache
@Deprecated
public void waitUntilClusterCoherent()
throws java.lang.UnsupportedOperationException
waitUntilClusterBulkLoadComplete() instead
waitUntilClusterCoherent in interface Ehcachejava.lang.UnsupportedOperationException - if this cache does not support coherence, like RMI replication
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
MemoryStore or DiskStore has been created.
A new, empty, RegisteredEventListeners is created on clone.
clone in interface Ehcacheclone in class java.lang.ObjectCache
java.lang.CloneNotSupportedException
public Element putIfAbsent(Element element)
throws java.lang.NullPointerException
putIfAbsent in interface Ehcacheelement - element to be added
java.lang.NullPointerException - if the element is null, or has a null key
public boolean removeElement(Element element)
throws java.lang.NullPointerException
removeElement in interface Ehcacheelement - Element to be removed
java.lang.NullPointerException - if the element is null, or has a null key
public boolean replace(Element old,
Element element)
throws java.lang.NullPointerException,
java.lang.IllegalArgumentException
replace in interface Ehcacheold - Element to be test againstelement - Element to be cached
java.lang.NullPointerException - if the either Element is null or has a null key
java.lang.IllegalArgumentException - if the two Element keys are non-null but not equal
public Element replace(Element element)
throws java.lang.NullPointerException
replace in interface Ehcacheelement - Element to be cached
java.lang.NullPointerException - if the Element is null or has a null keypublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
addPropertyChangeListener in interface EhcacheEhcache.addPropertyChangeListener(java.beans.PropertyChangeListener)public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener in interface EhcacheEhcache.removePropertyChangeListener(java.beans.PropertyChangeListener)public java.lang.String toString()
String representation of Cache.
toString in interface EhcachetoString in class java.lang.Objectpublic Query createQuery()
createQuery in interface Ehcache
public <T> Attribute<T> getSearchAttribute(java.lang.String attributeName)
throws CacheException
getSearchAttribute in interface EhcacheT - type of the attributeattributeName - the name of the attribute to retrieve
CacheException - if no such attribute is defined for the given namepublic boolean isSearchable()
isSearchable in interface Ehcachepublic long getAverageSearchTime()
getAverageSearchTime in interface Ehcachepublic long getSearchesPerSecond()
getSearchesPerSecond in interface Ehcachepublic void acquireReadLockOnKey(java.lang.Object key)
acquireReadLockOnKey in interface Ehcachekey - - The key that retrieves a value that you want to protect via lockingpublic void acquireWriteLockOnKey(java.lang.Object key)
acquireWriteLockOnKey in interface Ehcachekey - - The key that retrieves a value that you want to protect via lockingpublic void releaseReadLockOnKey(java.lang.Object key)
releaseReadLockOnKey in interface Ehcachekey - - The key that retrieves a value that you want to protect via lockingpublic void releaseWriteLockOnKey(java.lang.Object key)
releaseWriteLockOnKey in interface Ehcachekey - - The key that retrieves a value that you want to protect via locking
public boolean tryReadLockOnKey(java.lang.Object key,
long timeout)
throws java.lang.InterruptedException
tryReadLockOnKey in interface Ehcachekey - - The key that retrieves a value that you want to protect via lockingtimeout - - millis until giveup on getting the lock
java.lang.InterruptedException
public boolean tryWriteLockOnKey(java.lang.Object key,
long timeout)
throws java.lang.InterruptedException
tryWriteLockOnKey in interface Ehcachekey - - The key that retrieves a value that you want to protect via lockingtimeout - - millis until giveup on getting the lock
java.lang.InterruptedExceptionpublic boolean isReadLockedByCurrentThread(java.lang.Object key)
isReadLockedByCurrentThread in interface Ehcachepublic boolean isWriteLockedByCurrentThread(java.lang.Object key)
isWriteLockedByCurrentThread in interface Ehcache
public boolean isClusterBulkLoadEnabled()
throws java.lang.UnsupportedOperationException,
TerracottaNotRunningException
Ehcache.isNodeBulkLoadEnabled() returns true, this method will always return true.
Applies to caches clustered with Terracotta only.
isClusterBulkLoadEnabled in interface Ehcachejava.lang.UnsupportedOperationException - if the cache is not clustered with Terracotta
TerracottaNotRunningException
public boolean isNodeBulkLoadEnabled()
throws java.lang.UnsupportedOperationException,
TerracottaNotRunningException
Ehcache.isClusterBulkLoadEnabled() method will always return true.
Applies to caches clustered with Terracotta only.
isNodeBulkLoadEnabled in interface Ehcachejava.lang.UnsupportedOperationException - if the cache is not clustered with Terracotta
TerracottaNotRunningException
public void setNodeBulkLoadEnabled(boolean enabledBulkLoad)
throws java.lang.UnsupportedOperationException,
TerracottaNotRunningException
setBulkLoadEnabled(true) when the cache is already in bulk-load mode or
calling setBulkLoadEnabled(false) when already NOT in bulk-load mode will be a no-op.
Applies to caches clustered with Terracotta only.
When using Terracotta clustered caches with nonstop enabled, the timeout used by this method is
NonstopConfiguration.getBulkOpsTimeoutMultiplyFactor() times the timeout value in the nonstop config.
setNodeBulkLoadEnabled in interface EhcacheenabledBulkLoad - true enables bulk-load, false disables it if not already disabled
java.lang.UnsupportedOperationException - if the cache is not clustered with Terracotta
TerracottaNotRunningException
public void waitUntilClusterBulkLoadComplete()
throws java.lang.UnsupportedOperationException,
TerracottaNotRunningException
waitUntilClusterBulkLoadComplete in interface Ehcachejava.lang.UnsupportedOperationException - if the cache is not clustered with Terracotta
TerracottaNotRunningException
|
ehcache | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||