|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.ehcache.constructs.locking.ExplicitLockingCache
public class ExplicitLockingCache
See description in package.html
| Field Summary | |
|---|---|
protected net.sf.ehcache.Ehcache |
cache
The backing Cache |
| Constructor Summary | |
|---|---|
ExplicitLockingCache(net.sf.ehcache.Ehcache cache)
Constructor for this decorated cache |
|
| 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 |
bootstrap()
Bootstrap command. |
long |
calculateInMemorySize()
Gets the size of the memory store for this cache Warning: This method can be very expensive to run. |
void |
clearStatistics()
Resets statistics counters back to 0. |
java.lang.Object |
clone()
Clones a cache. |
void |
disableDynamicFeatures()
|
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. |
net.sf.ehcache.Element |
get(java.lang.Object key)
Looks up an entry. |
net.sf.ehcache.Element |
get(java.io.Serializable key)
Gets an element from the cache. |
java.util.Map |
getAllWithLoader(java.util.Collection keys,
java.lang.Object loaderArgument)
This method is not appropriate to use with BlockingCache. |
float |
getAverageGetTime()
The average get time in ms. |
net.sf.ehcache.bootstrap.BootstrapCacheLoader |
getBootstrapCacheLoader()
Accessor for the BootstrapCacheLoader associated with this cache. |
protected net.sf.ehcache.Ehcache |
getCache()
Retrieve the EHCache backing cache |
net.sf.ehcache.config.CacheConfiguration |
getCacheConfiguration()
Gets the cache configuration this cache was created with. |
net.sf.ehcache.event.RegisteredEventListeners |
getCacheEventNotificationService()
Use this to access the service in order to register and unregister listeners |
net.sf.ehcache.exceptionhandler.CacheExceptionHandler |
getCacheExceptionHandler()
Sets an ExceptionHandler on the Cache. |
net.sf.ehcache.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()
|
java.util.List |
getKeys()
Returns the keys for this cache. |
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. |
net.sf.ehcache.statistics.LiveCacheStatistics |
getLiveCacheStatistics()
|
protected net.sf.ehcache.concurrent.Sync |
getLockForKey(java.lang.Object key)
Gets the lock for a given key |
long |
getMemoryStoreSize()
Returns the number of elements in the memory store. |
java.lang.String |
getName()
Returns this cache's name |
net.sf.ehcache.Element |
getQuiet(java.lang.Object key)
Gets an element from the cache, without updating Element statistics. |
net.sf.ehcache.Element |
getQuiet(java.io.Serializable key)
Gets an element from the cache, without updating Element statistics. |
java.util.List<net.sf.ehcache.extension.CacheExtension> |
getRegisteredCacheExtensions()
|
java.util.List<net.sf.ehcache.loader.CacheLoader> |
getRegisteredCacheLoaders()
|
net.sf.ehcache.writer.CacheWriter |
getRegisteredCacheWriter()
|
net.sf.ehcache.statistics.sampled.SampledCacheStatistics |
getSampledCacheStatistics()
|
int |
getSize()
Gets the size of the cache. |
int |
getSizeBasedOnAccuracy(int statisticsAccuracy)
|
net.sf.ehcache.Statistics |
getStatistics()
Gets an immutable Statistics object representing the Cache statistics at the time. |
int |
getStatisticsAccuracy()
Accurately measuring statistics can be expensive. |
net.sf.ehcache.Status |
getStatus()
Gets the status attribute of the Cache. |
net.sf.ehcache.Element |
getWithLoader(java.lang.Object key,
net.sf.ehcache.loader.CacheLoader loader,
java.lang.Object loaderArgument)
This method is not appropriate to use with BlockingCache. |
net.sf.ehcache.writer.CacheWriterManager |
getWriterManager()
|
void |
initialise()
This method creates a memory or disk store and makes the cache ready to accept elements |
boolean |
isClusterCoherent()
|
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(net.sf.ehcache.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 |
isNodeCoherent()
|
boolean |
isSampledStatisticsEnabled()
|
boolean |
isStatisticsEnabled()
|
boolean |
isValueInCache(java.lang.Object value)
An extremely expensive check to see if the value exists in the cache. |
java.lang.String |
liveness()
Synchronized version of getName to test liveness of the object lock. |
void |
load(java.lang.Object key)
This method is not appropriate to use with BlockingCache. |
void |
loadAll(java.util.Collection keys,
java.lang.Object argument)
This method is not appropriate to use with BlockingCache. |
void |
put(net.sf.ehcache.Element element)
Adds an entry and unlocks it |
void |
put(net.sf.ehcache.Element element,
boolean doNotNotifyCacheReplicators)
Put an element in the cache. |
boolean |
putIfAbsent(net.sf.ehcache.Element element)
Put an element in the cache if an element for the key doesn't already exist |
void |
putQuiet(net.sf.ehcache.Element element)
Put an element in the cache, without updating statistics, or updating listeners. |
void |
putWithWriter(net.sf.ehcache.Element element)
|
void |
registerCacheExtension(net.sf.ehcache.extension.CacheExtension cacheExtension)
Register a CacheExtension with the cache. |
void |
registerCacheLoader(net.sf.ehcache.loader.CacheLoader cacheLoader)
Register a CacheLoader with the cache. |
void |
registerCacheUsageListener(net.sf.ehcache.statistics.CacheUsageListener cacheUsageListener)
|
void |
registerCacheWriter(net.sf.ehcache.writer.CacheWriter cacheWriter)
|
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(net.sf.ehcache.statistics.CacheUsageListener cacheUsageListener)
|
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)
|
void |
setBootstrapCacheLoader(net.sf.ehcache.bootstrap.BootstrapCacheLoader bootstrapCacheLoader)
Sets the bootstrap cache loader. |
void |
setCacheExceptionHandler(net.sf.ehcache.exceptionhandler.CacheExceptionHandler cacheExceptionHandler)
Sets an ExceptionHandler on the Cache. |
void |
setCacheManager(net.sf.ehcache.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 |
setNodeCoherent(boolean coherent)
|
void |
setSampledStatisticsEnabled(boolean enabledStatistics)
|
void |
setStatisticsAccuracy(int statisticsAccuracy)
Sets the statistics accuracy. |
void |
setStatisticsEnabled(boolean enabledStatistics)
|
void |
setTransactionManagerLookup(net.sf.ehcache.transaction.manager.TransactionManagerLookup transactionManagerLookup)
|
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(net.sf.ehcache.extension.CacheExtension cacheExtension)
Unregister a CacheExtension with the cache. |
void |
unregisterCacheLoader(net.sf.ehcache.loader.CacheLoader cacheLoader)
Unregister a CacheLoader with the cache. |
void |
unregisterCacheWriter()
|
void |
waitUntilClusterCoherent()
|
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface net.sf.ehcache.Ehcache |
|---|
toString |
| Field Detail |
|---|
protected final net.sf.ehcache.Ehcache cache
| Constructor Detail |
|---|
public ExplicitLockingCache(net.sf.ehcache.Ehcache cache)
throws net.sf.ehcache.CacheException
cache - the backing cache
net.sf.ehcache.CacheException| Method Detail |
|---|
protected net.sf.ehcache.Ehcache getCache()
public java.lang.String getName()
getName in interface net.sf.ehcache.Ehcachepublic void setName(java.lang.String name)
setName in interface net.sf.ehcache.Ehcachename - the name of the cache. Should not be null.
public boolean isExpired(net.sf.ehcache.Element element)
throws java.lang.IllegalStateException,
java.lang.NullPointerException
isExpired in interface net.sf.ehcache.Ehcachejava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
java.lang.NullPointerException - if the element is null
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in interface net.sf.ehcache.Ehcacheclone in class java.lang.ObjectCache
java.lang.CloneNotSupportedExceptionpublic net.sf.ehcache.event.RegisteredEventListeners getCacheEventNotificationService()
getCacheEventNotificationService in interface net.sf.ehcache.Ehcachepublic boolean isElementInMemory(java.io.Serializable key)
isElementInMemory in interface net.sf.ehcache.Ehcachepublic boolean isElementInMemory(java.lang.Object key)
isElementInMemory in interface net.sf.ehcache.Ehcachepublic boolean isElementOnDisk(java.io.Serializable key)
isElementOnDisk in interface net.sf.ehcache.Ehcachepublic boolean isElementOnDisk(java.lang.Object key)
isElementOnDisk in interface net.sf.ehcache.Ehcachepublic java.lang.String getGuid()
getGuid in interface net.sf.ehcache.Ehcachepublic net.sf.ehcache.CacheManager getCacheManager()
getCacheManager in interface net.sf.ehcache.Ehcachepublic void clearStatistics()
clearStatistics in interface net.sf.ehcache.Ehcachepublic int getStatisticsAccuracy()
getStatisticsAccuracy in interface net.sf.ehcache.EhcacheStatistics.STATISTICS_ACCURACY_BEST_EFFORT ,
Statistics.STATISTICS_ACCURACY_GUARANTEED, Statistics.STATISTICS_ACCURACY_NONEpublic void setStatisticsAccuracy(int statisticsAccuracy)
setStatisticsAccuracy in interface net.sf.ehcache.EhcachestatisticsAccuracy - one of Statistics.STATISTICS_ACCURACY_BEST_EFFORT ,
Statistics.STATISTICS_ACCURACY_GUARANTEED ,
Statistics.STATISTICS_ACCURACY_NONEpublic void evictExpiredElements()
evictExpiredElements in interface net.sf.ehcache.Ehcachepublic boolean isKeyInCache(java.lang.Object key)
isKeyInCache in interface net.sf.ehcache.Ehcachekey - the key to check for
public boolean isValueInCache(java.lang.Object value)
isValueInCache in interface net.sf.ehcache.Ehcachevalue - to check for
public net.sf.ehcache.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 net.sf.ehcache.Ehcachejava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
public net.sf.ehcache.statistics.LiveCacheStatistics getLiveCacheStatistics()
throws java.lang.IllegalStateException
getLiveCacheStatistics in interface net.sf.ehcache.Ehcachejava.lang.IllegalStateExceptionpublic void setCacheManager(net.sf.ehcache.CacheManager cacheManager)
setCacheManager in interface net.sf.ehcache.EhcachecacheManager - the CacheManager this cache belongs topublic net.sf.ehcache.bootstrap.BootstrapCacheLoader getBootstrapCacheLoader()
getBootstrapCacheLoader in interface net.sf.ehcache.Ehcache
public void setBootstrapCacheLoader(net.sf.ehcache.bootstrap.BootstrapCacheLoader bootstrapCacheLoader)
throws net.sf.ehcache.CacheException
setBootstrapCacheLoader in interface net.sf.ehcache.EhcachebootstrapCacheLoader - the loader to be used
net.sf.ehcache.CacheException - if this method is called after the cache is initialized
public void setDiskStorePath(java.lang.String diskStorePath)
throws net.sf.ehcache.CacheException
setDiskStorePath in interface net.sf.ehcache.EhcachediskStorePath - the new path to be used.
net.sf.ehcache.CacheException - if this method is called after the cache is initializedpublic void initialise()
initialise in interface net.sf.ehcache.Ehcachepublic void bootstrap()
bootstrap in interface net.sf.ehcache.Ehcache
public void dispose()
throws java.lang.IllegalStateException
dispose in interface net.sf.ehcache.Ehcachejava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVEpublic net.sf.ehcache.config.CacheConfiguration getCacheConfiguration()
getCacheConfiguration in interface net.sf.ehcache.Ehcache
public net.sf.ehcache.Element get(java.lang.Object key)
throws java.lang.RuntimeException,
net.sf.ehcache.constructs.blocking.LockTimeoutException
put(net.sf.ehcache.Element) is done to put an Element in.
If a put is not done, the lock is never released.
If this method throws an exception, it is the responsibility of the caller to catch that exception and call
put(new Element(key, null)); to release the lock acquired. See
SelfPopulatingCache for an example.
Note. If a LockTimeoutException is thrown while doing a get it means the lock was never acquired, therefore it is a
threading error to call put(net.sf.ehcache.Element)
get in interface net.sf.ehcache.Ehcachenet.sf.ehcache.constructs.blocking.LockTimeoutException - if timeout millis is non zero and this method has been unable to acquire a lock in that time
java.lang.RuntimeException - if thrown the lock will not released. Catch and call put(new Element(key, null)); to release the lock
acquired.public void put(net.sf.ehcache.Element element)
put in interface net.sf.ehcache.Ehcache
public void put(net.sf.ehcache.Element element,
boolean doNotNotifyCacheReplicators)
throws java.lang.IllegalArgumentException,
java.lang.IllegalStateException,
net.sf.ehcache.CacheException
put in interface net.sf.ehcache.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.IllegalStateException - if the cache is not Status.STATUS_ALIVE
java.lang.IllegalArgumentException - if the element is null
net.sf.ehcache.CacheException
public void putQuiet(net.sf.ehcache.Element element)
throws java.lang.IllegalArgumentException,
java.lang.IllegalStateException,
net.sf.ehcache.CacheException
getQuiet(java.io.Serializable)
putQuiet in interface net.sf.ehcache.Ehcacheelement - An object. If Serializable it can fully participate in replication and the DiskStore.
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
java.lang.IllegalArgumentException - if the element is null
net.sf.ehcache.CacheException
public net.sf.ehcache.Element get(java.io.Serializable key)
throws java.lang.IllegalStateException,
net.sf.ehcache.CacheException
getQuiet(Object) to peak into the Element to see
its last access time with get
get in interface net.sf.ehcache.Ehcachekey - a serializable value
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
net.sf.ehcache.CacheExceptionisExpired(net.sf.ehcache.Element)
public net.sf.ehcache.Element getQuiet(java.io.Serializable key)
throws java.lang.IllegalStateException,
net.sf.ehcache.CacheException
getQuiet in interface net.sf.ehcache.Ehcachekey - a serializable value
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
net.sf.ehcache.CacheExceptionisExpired(net.sf.ehcache.Element)
public net.sf.ehcache.Element getQuiet(java.lang.Object key)
throws java.lang.IllegalStateException,
net.sf.ehcache.CacheException
getQuiet in interface net.sf.ehcache.Ehcachekey - a serializable value
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
net.sf.ehcache.CacheExceptionisExpired(net.sf.ehcache.Element)
public java.util.List getKeys()
throws net.sf.ehcache.CacheException
getKeys in interface net.sf.ehcache.EhcacheObject keys for this cache. This is not a live set, so it will not track changes to the key set.
net.sf.ehcache.CacheException
public java.util.List getKeysWithExpiryCheck()
throws java.lang.IllegalStateException,
net.sf.ehcache.CacheException
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 net.sf.ehcache.EhcacheObject keys
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
net.sf.ehcache.CacheException
public java.util.List getKeysNoDuplicateCheck()
throws java.lang.IllegalStateException
getKeysNoDuplicateCheck in interface net.sf.ehcache.EhcacheObject keys
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, but only if an Element with the key actually existed.
remove in interface net.sf.ehcache.Ehcachekey - the key to remove
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 net.sf.ehcache.Ehcachekey - the key to remove
java.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 net.sf.ehcache.Ehcachekey - the key to removedoNotNotifyCacheReplicators - 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,
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 net.sf.ehcache.Ehcachekey - the key to removedoNotNotifyCacheReplicators - 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 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 net.sf.ehcache.Ehcachekey - the key to remove
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
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 net.sf.ehcache.Ehcachekey - the key to remove
java.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
public void removeAll()
throws java.lang.IllegalStateException,
net.sf.ehcache.CacheException
removeAll in interface net.sf.ehcache.Ehcachejava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
net.sf.ehcache.CacheException
public void removeAll(boolean doNotNotifyCacheReplicators)
throws java.lang.IllegalStateException,
net.sf.ehcache.CacheException
removeAll in interface net.sf.ehcache.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
net.sf.ehcache.CacheException
public void flush()
throws java.lang.IllegalStateException,
net.sf.ehcache.CacheException
flush in interface net.sf.ehcache.Ehcachejava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
net.sf.ehcache.CacheException
public int getSize()
throws java.lang.IllegalStateException,
net.sf.ehcache.CacheException
Elements in the MemoryStore plus the number of Elements in
the net.sf.ehcache.store.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 getKeysWithExpiryCheck().size(), although see that method
for the approximate time that would take.
To get a very fast result, use getKeysNoDuplicateCheck().size(). If the disk store is being used, there will be some
duplicates.
getSize in interface net.sf.ehcache.Ehcachejava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
net.sf.ehcache.CacheException
public int getSizeBasedOnAccuracy(int statisticsAccuracy)
throws java.lang.IllegalStateException,
net.sf.ehcache.CacheException
getSizeBasedOnAccuracy in interface net.sf.ehcache.Ehcachejava.lang.IllegalStateException
net.sf.ehcache.CacheException
public long calculateInMemorySize()
throws java.lang.IllegalStateException,
net.sf.ehcache.CacheException
calculateInMemorySize in interface net.sf.ehcache.Ehcachejava.lang.IllegalStateException
net.sf.ehcache.CacheException
public long getMemoryStoreSize()
throws java.lang.IllegalStateException
getMemoryStoreSize in interface net.sf.ehcache.Ehcachejava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVE
public int getDiskStoreSize()
throws java.lang.IllegalStateException
getDiskStoreSize in interface net.sf.ehcache.Ehcachejava.lang.IllegalStateException - if the cache is not Status.STATUS_ALIVEpublic net.sf.ehcache.Status getStatus()
getStatus in interface net.sf.ehcache.Ehcachepublic java.lang.String liveness()
public void registerCacheExtension(net.sf.ehcache.extension.CacheExtension cacheExtension)
CacheExtension with the cache. It will then be tied into the cache lifecycle.
registerCacheExtension in interface net.sf.ehcache.Ehcachepublic void unregisterCacheExtension(net.sf.ehcache.extension.CacheExtension cacheExtension)
CacheExtension with the cache. It will then be detached from the cache lifecycle.
unregisterCacheExtension in interface net.sf.ehcache.Ehcachepublic java.util.List<net.sf.ehcache.extension.CacheExtension> getRegisteredCacheExtensions()
getRegisteredCacheExtensions in interface net.sf.ehcache.Ehcachepublic float getAverageGetTime()
getAverageGetTime in interface net.sf.ehcache.Ehcachepublic void setCacheExceptionHandler(net.sf.ehcache.exceptionhandler.CacheExceptionHandler cacheExceptionHandler)
setCacheExceptionHandler in interface net.sf.ehcache.Ehcachepublic net.sf.ehcache.exceptionhandler.CacheExceptionHandler getCacheExceptionHandler()
getCacheExceptionHandler in interface net.sf.ehcache.Ehcachepublic void registerCacheLoader(net.sf.ehcache.loader.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 net.sf.ehcache.EhcachecacheLoader - A Cache Loader to registerpublic void unregisterCacheLoader(net.sf.ehcache.loader.CacheLoader cacheLoader)
CacheLoader with the cache. It will then be detached from the cache lifecycle.
unregisterCacheLoader in interface net.sf.ehcache.EhcachecacheLoader - A Cache Loader to unregisterpublic java.util.List<net.sf.ehcache.loader.CacheLoader> getRegisteredCacheLoaders()
getRegisteredCacheLoaders in interface net.sf.ehcache.Ehcache
public net.sf.ehcache.Element getWithLoader(java.lang.Object key,
net.sf.ehcache.loader.CacheLoader loader,
java.lang.Object loaderArgument)
throws net.sf.ehcache.CacheException
getWithLoader in interface net.sf.ehcache.Ehcachenet.sf.ehcache.CacheException - if this method is called
public java.util.Map getAllWithLoader(java.util.Collection keys,
java.lang.Object loaderArgument)
throws net.sf.ehcache.CacheException
getAllWithLoader in interface net.sf.ehcache.Ehcachenet.sf.ehcache.CacheException - if this method is called
public void load(java.lang.Object key)
throws net.sf.ehcache.CacheException
load in interface net.sf.ehcache.Ehcachenet.sf.ehcache.CacheException - if this method is called
public void loadAll(java.util.Collection keys,
java.lang.Object argument)
throws net.sf.ehcache.CacheException
loadAll in interface net.sf.ehcache.Ehcachenet.sf.ehcache.CacheException - if this method is calledpublic boolean isDisabled()
setDisabled(boolean) method.
By default caches are enabled on creation, unless the net.sf.ehcache.disabled system property is set.
isDisabled in interface net.sf.ehcache.Ehcachepublic void setDisabled(boolean disabled)
net.sf.ehcache.disabled
system property is set
setDisabled in interface net.sf.ehcache.Ehcachedisabled - true if you wish to disable, false to enableisDisabled()
public void registerCacheUsageListener(net.sf.ehcache.statistics.CacheUsageListener cacheUsageListener)
throws java.lang.IllegalStateException
registerCacheUsageListener in interface net.sf.ehcache.Ehcachejava.lang.IllegalStateException
public void removeCacheUsageListener(net.sf.ehcache.statistics.CacheUsageListener cacheUsageListener)
throws java.lang.IllegalStateException
removeCacheUsageListener in interface net.sf.ehcache.Ehcachejava.lang.IllegalStateExceptionpublic boolean isStatisticsEnabled()
isStatisticsEnabled in interface net.sf.ehcache.Ehcachepublic void setStatisticsEnabled(boolean enabledStatistics)
setStatisticsEnabled in interface net.sf.ehcache.Ehcachepublic net.sf.ehcache.statistics.sampled.SampledCacheStatistics getSampledCacheStatistics()
getSampledCacheStatistics in interface net.sf.ehcache.Ehcachepublic void setSampledStatisticsEnabled(boolean enabledStatistics)
setSampledStatisticsEnabled in interface net.sf.ehcache.Ehcachepublic boolean isSampledStatisticsEnabled()
isSampledStatisticsEnabled in interface net.sf.ehcache.EhcacheEhcache.isSampledStatisticsEnabled()public java.lang.Object getInternalContext()
getInternalContext in interface net.sf.ehcache.Ehcacheprotected net.sf.ehcache.concurrent.Sync getLockForKey(java.lang.Object key)
key -
public void acquireReadLockOnKey(java.lang.Object key)
key - - The key that retrieves a value that you want to protect via lockingpublic void acquireWriteLockOnKey(java.lang.Object key)
key - - The key that retrieves a value that you want to protect via lockingpublic void releaseReadLockOnKey(java.lang.Object key)
key - - The key that retrieves a value that you want to protect via lockingpublic void releaseWriteLockOnKey(java.lang.Object key)
key - - 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
key - - 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
key - - The key that retrieves a value that you want to protect via lockingtimeout - - millis until giveup on getting the lock
java.lang.InterruptedExceptionpublic boolean putIfAbsent(net.sf.ehcache.Element element)
element - to add to the cache
public void disableDynamicFeatures()
disableDynamicFeatures in interface net.sf.ehcache.Ehcache
public void putWithWriter(net.sf.ehcache.Element element)
throws java.lang.IllegalArgumentException,
java.lang.IllegalStateException,
net.sf.ehcache.CacheException
putWithWriter in interface net.sf.ehcache.Ehcachejava.lang.IllegalArgumentException
java.lang.IllegalStateException
net.sf.ehcache.CacheException
public boolean removeWithWriter(java.lang.Object key)
throws java.lang.IllegalStateException
removeWithWriter in interface net.sf.ehcache.Ehcachejava.lang.IllegalStateExceptionpublic void registerCacheWriter(net.sf.ehcache.writer.CacheWriter cacheWriter)
registerCacheWriter in interface net.sf.ehcache.Ehcachepublic void unregisterCacheWriter()
unregisterCacheWriter in interface net.sf.ehcache.Ehcachepublic net.sf.ehcache.writer.CacheWriter getRegisteredCacheWriter()
getRegisteredCacheWriter in interface net.sf.ehcache.Ehcachepublic net.sf.ehcache.writer.CacheWriterManager getWriterManager()
getWriterManager in interface net.sf.ehcache.Ehcachepublic boolean isNodeCoherent()
isNodeCoherent in interface net.sf.ehcache.Ehcachepublic boolean isClusterCoherent()
isClusterCoherent in interface net.sf.ehcache.Ehcache
public void setNodeCoherent(boolean coherent)
throws java.lang.UnsupportedOperationException
setNodeCoherent in interface net.sf.ehcache.Ehcachejava.lang.UnsupportedOperationExceptionpublic void waitUntilClusterCoherent()
waitUntilClusterCoherent in interface net.sf.ehcache.Ehcachepublic void setTransactionManagerLookup(net.sf.ehcache.transaction.manager.TransactionManagerLookup transactionManagerLookup)
setTransactionManagerLookup in interface net.sf.ehcache.Ehcache
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||