public class ClassLoaderAwareCache extends Object implements Ehcache
| Modifier and Type | Field and Description |
|---|---|
protected Ehcache |
cache
Used by InternalClassLoaderAwareCache
|
protected ClassLoader |
classLoader
Used by InternalClassLoaderAwareCache
|
| Constructor and Description |
|---|
ClassLoaderAwareCache(Ehcache cache,
ClassLoader classLoader)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
acquireReadLockOnKey(Object arg0)
Acquires the proper read lock for a given cache key
|
void |
acquireWriteLockOnKey(Object arg0)
Acquires the proper write lock for a given cache key
|
void |
addPropertyChangeListener(PropertyChangeListener arg0)
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
|
long |
calculateOnDiskSize()
Gets the size of the on-disk store for this cache
|
void |
clearStatistics()
Resets statistics counters back to 0.
|
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(Object arg0)
Gets an element from the cache.
|
Element |
get(Serializable arg0)
Gets an element from the cache.
|
Map |
getAll(Collection arg0)
Gets all the elements from the cache for the keys provided.
|
Map |
getAllWithLoader(Collection arg0,
Object arg1)
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.
|
String |
getGuid()
The GUID for this cache instance can be used to determine whether two cache instance references
are pointing to the same cache.
|
Object |
getInternalContext()
This should not be used
return some internal context (generally will be null)
|
List |
getKeys()
Returns a list of all elements in the cache, whether or not they are expired.
|
List |
getKeysNoDuplicateCheck()
Returns a list of all elements in the cache, whether or not they are expired.
|
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.
|
String |
getName()
Gets the cache name.
|
long |
getOffHeapStoreSize()
Returns the number of elements in the off-heap store.
|
Element |
getQuiet(Object arg0)
Gets an element from the cache, without updating Element statistics.
|
Element |
getQuiet(Serializable arg0)
Gets an element from the cache, without updating Element statistics.
|
List |
getRegisteredCacheExtensions() |
List |
getRegisteredCacheLoaders() |
CacheWriter |
getRegisteredCacheWriter()
Retrieves the
CacheWriter that was registered for this cache. |
SampledCacheStatistics |
getSampledCacheStatistics()
Returns sampled statistics for this cache.
|
Attribute |
getSearchAttribute(String arg0)
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 arg0)
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(Object arg0,
CacheLoader arg1,
Object arg2)
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.
|
boolean |
hasAbortedSizeOf()
Check if the cache may contain elements which the SizeOf engine could not fully size.
|
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()
Returns true if the cache is in coherent mode cluster-wide.
|
boolean |
isDisabled()
Whether this cache is disabled.
|
boolean |
isElementInMemory(Object arg0)
Whether an Element is stored in the cache in Memory, indicating a very low cost of retrieval.
|
boolean |
isElementInMemory(Serializable arg0)
Whether an Element is stored in the cache in Memory, indicating a very low cost of retrieval.
|
boolean |
isElementOnDisk(Object arg0)
Whether an Element is stored in the cache on Disk, indicating a higher cost of retrieval.
|
boolean |
isElementOnDisk(Serializable arg0)
Whether an Element is stored in the cache on Disk, indicating a higher cost of retrieval.
|
boolean |
isExpired(Element arg0)
Checks whether this cache element has expired.
|
boolean |
isKeyInCache(Object arg0)
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()
Returns true if the cache is in coherent mode for the current node.
|
boolean |
isPinned(Object arg0)
Check if the key is pinned
|
boolean |
isReadLockedByCurrentThread(Object arg0)
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(Object arg0)
An extremely expensive check to see if the value exists in the cache.
|
boolean |
isWriteLockedByCurrentThread(Object arg0)
Returns true if a write lock for the key is held by the current thread
|
void |
load(Object arg0)
The load method provides a means to "pre load" the cache.
|
void |
loadAll(Collection arg0,
Object arg1)
The loadAll method provides a means to "pre load" objects into the cache.
|
static void |
main(String[] args)
Generator for the method bodies
|
void |
put(Element arg0)
Put an element in the cache.
|
void |
put(Element arg0,
boolean arg1)
Put an element in the cache.
|
void |
putAll(Collection arg0)
Puts a collection of elements in to the cache.
|
Element |
putIfAbsent(Element arg0)
Put an element in the cache if no element is currently mapped to the elements key.
|
Element |
putIfAbsent(Element arg0,
boolean arg1)
Put an element in the cache if no element is currently mapped to the elements key.
|
void |
putQuiet(Element arg0)
Put an element in the cache, without updating statistics, or updating listeners.
|
void |
putWithWriter(Element arg0)
Put an element in the cache writing through a CacheWriter.
|
void |
registerCacheExtension(CacheExtension arg0)
Register a
CacheExtension with the cache. |
void |
registerCacheLoader(CacheLoader arg0)
Register a
CacheLoader with the cache. |
void |
registerCacheUsageListener(CacheUsageListener arg0)
Registers a
CacheUsageListener which will be notified of the
cache
usage. |
void |
registerCacheWriter(CacheWriter arg0)
Register the
CacheWriter for this cache. |
void |
registerDynamicAttributesExtractor(DynamicAttributesExtractor extractor)
Allows user to register a dynamic attribute extractor with a searchable cache that is dynamically indexable,
as indicated by its configuration.
|
void |
releaseReadLockOnKey(Object arg0)
Release a held read lock for the passed in key
|
void |
releaseWriteLockOnKey(Object arg0)
Release a held write lock for the passed in key
|
boolean |
remove(Object arg0)
Removes an
Element from the Cache. |
boolean |
remove(Object arg0,
boolean arg1)
Removes an
Element from the Cache. |
boolean |
remove(Serializable arg0)
Removes an
Element from the Cache. |
boolean |
remove(Serializable arg0,
boolean arg1)
Removes an
Element from the Cache. |
void |
removeAll()
Removes all cached items.
|
void |
removeAll(boolean arg0)
Removes all cached items.
|
void |
removeAll(Collection arg0)
Removes given set of
Element from the Cache. |
void |
removeAll(Collection arg0,
boolean arg1)
Removes all cached items.
|
void |
removeCacheUsageListener(CacheUsageListener arg0)
Remove an already registered
CacheUsageListener, if any. |
boolean |
removeElement(Element arg0)
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(PropertyChangeListener arg0)
Remove a PropertyChangeListener.
|
boolean |
removeQuiet(Object arg0)
Removes an
Element from the Cache, without notifying listeners. |
boolean |
removeQuiet(Serializable arg0)
Removes an
Element from the Cache, without notifying listeners. |
boolean |
removeWithWriter(Object arg0)
Removes an
Element from the Cache and any stores it might be in. |
Element |
replace(Element arg0)
Replace the cached element only if an Element is currently cached for this key
|
boolean |
replace(Element arg0,
Element arg1)
Replace the cached element only if the current Element is equal to the supplied old Element.
|
void |
setBootstrapCacheLoader(BootstrapCacheLoader arg0)
Sets the bootstrap cache loader.
|
void |
setCacheExceptionHandler(CacheExceptionHandler arg0)
Sets an ExceptionHandler on the Cache.
|
void |
setCacheManager(CacheManager arg0)
Sets the CacheManager
|
void |
setDisabled(boolean arg0)
Disables or enables this cache.
|
void |
setName(String arg0)
Sets the cache name which will name.
|
void |
setNodeBulkLoadEnabled(boolean arg0)
Enable/disable bulk-load mode in this node for this cache.
|
void |
setNodeCoherent(boolean arg0)
Sets the cache in coherent or incoherent mode depending on the parameter on this node.
|
void |
setPinned(Object arg0,
boolean arg1)
Mark the key as pinned or not.
|
void |
setSampledStatisticsEnabled(boolean arg0)
Enable/disable sampled statistics collection.
|
void |
setStatisticsAccuracy(int arg0)
Sets the statistics accuracy.
|
void |
setStatisticsEnabled(boolean arg0)
Enable/disable statistics collection.
|
void |
setTransactionManagerLookup(TransactionManagerLookup arg0)
This class is used to access the transaction manager used during XA.
|
String |
toString()
|
boolean |
tryReadLockOnKey(Object arg0,
long arg1)
Try to get a read lock on a given key.
|
boolean |
tryWriteLockOnKey(Object arg0,
long arg1)
Try to get a write lock on a given key.
|
void |
unpinAll()
unpin all pinned keys
|
void |
unregisterCacheExtension(CacheExtension arg0)
Unregister a
CacheExtension with the cache. |
void |
unregisterCacheLoader(CacheLoader arg0)
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()
This method waits until the cache is in coherent mode in all the connected nodes.
|
protected final ClassLoader classLoader
protected final Ehcache cache
public ClassLoaderAwareCache(Ehcache cache, ClassLoader classLoader)
cache - wrapped cacheclassLoader - loader to set Thread context loader to for duration of cache opeartionpublic static void main(String[] args)
args - public void putQuiet(Element arg0) throws IllegalArgumentException, IllegalStateException, CacheException
Ehcache.getQuiet(java.io.Serializable)putQuiet in interface Ehcachearg0 - An object. If Serializable it can fully participate in replication and the DiskStore.IllegalArgumentException - if the element is nullIllegalStateException - if the cache is not Status.STATUS_ALIVECacheExceptionpublic void putWithWriter(Element arg0) throws IllegalArgumentException, IllegalStateException, CacheException
putWithWriter in interface Ehcachearg0 - An object. If Serializable it can fully participate in replication and the DiskStore.IllegalArgumentException - if the element is nullIllegalStateException - if the cache is not Status.STATUS_ALIVECacheException - if no CacheWriter was registeredpublic Map getAll(Collection arg0) throws IllegalStateException, CacheException, NullPointerException
Ehcache.getQuiet(Object) to peek into the Element to see its last access time with getgetAll in interface Ehcachearg0 - a collection of keys for which value is to be fetchedIllegalStateException - if the cache is not Status.STATUS_ALIVENullPointerException - if any key is null in the collectionCacheExceptionEhcache.isExpired(net.sf.ehcache.Element)public Element getQuiet(Serializable arg0) throws IllegalStateException, CacheException
getQuiet in interface Ehcachearg0 - a serializable valueIllegalStateException - if the cache is not Status.STATUS_ALIVECacheExceptionEhcache.isExpired(net.sf.ehcache.Element)public Element getQuiet(Object arg0) throws IllegalStateException, CacheException
getQuiet in interface Ehcachearg0 - a serializable valueIllegalStateException - if the cache is not Status.STATUS_ALIVECacheExceptionEhcache.isExpired(net.sf.ehcache.Element)public List getKeysWithExpiryCheck() throws 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 keysIllegalStateException - if the cache is not Status.STATUS_ALIVECacheExceptionpublic List getKeysNoDuplicateCheck() throws IllegalStateException
getKeysNoDuplicateCheck in interface EhcacheObject keysIllegalStateException - if the cache is not Status.STATUS_ALIVEpublic boolean removeQuiet(Serializable arg0) throws IllegalStateException
Element from the Cache, without notifying listeners. This also removes it from any
stores it may be in.
removeQuiet in interface EhcacheIllegalStateException - if the cache is not Status.STATUS_ALIVEpublic boolean removeQuiet(Object arg0) throws IllegalStateException
Element from the Cache, without notifying listeners. This also removes it from any
stores it may be in.
removeQuiet in interface EhcacheIllegalStateException - if the cache is not Status.STATUS_ALIVEpublic boolean removeWithWriter(Object arg0) throws 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 EhcacheIllegalStateException - if the cache is not Status.STATUS_ALIVECacheException - if no CacheWriter was registeredpublic int getSizeBasedOnAccuracy(int arg0)
throws IllegalArgumentException,
IllegalStateException,
CacheException
getSizeBasedOnAccuracy in interface Ehcachearg0 - one of Statistics.STATISTICS_ACCURACY_BEST_EFFORT,
Statistics.STATISTICS_ACCURACY_GUARANTEED,
Statistics.STATISTICS_ACCURACY_NONEIllegalArgumentException - if the statisticsAccuracy is not one of the aboveIllegalStateException - if the cache is not
Status.STATUS_ALIVECacheExceptionpublic long calculateInMemorySize()
throws IllegalStateException,
CacheException
calculateInMemorySize in interface EhcacheIllegalStateExceptionCacheExceptionpublic long calculateOffHeapSize()
throws IllegalStateException,
CacheException
calculateOffHeapSize in interface EhcacheIllegalStateExceptionCacheExceptionpublic long calculateOnDiskSize()
throws IllegalStateException,
CacheException
calculateOnDiskSize in interface EhcacheIllegalStateExceptionCacheExceptionpublic boolean hasAbortedSizeOf()
hasAbortedSizeOf in interface Ehcachepublic long getMemoryStoreSize()
throws IllegalStateException
getMemoryStoreSize in interface EhcacheIllegalStateException - if the cache is not Status.STATUS_ALIVEpublic long getOffHeapStoreSize()
throws IllegalStateException
getOffHeapStoreSize in interface EhcacheIllegalStateException - if the cache is not Status.STATUS_ALIVEpublic int getDiskStoreSize()
throws IllegalStateException
getDiskStoreSize in interface EhcacheIllegalStateException - if the cache is not Status.STATUS_ALIVEpublic boolean isExpired(Element arg0) throws IllegalStateException, NullPointerException
isExpired in interface Ehcachearg0 - the element to checkIllegalStateException - if the cache is not Status.STATUS_ALIVENullPointerException - if the element is nullpublic RegisteredEventListeners getCacheEventNotificationService()
getCacheEventNotificationService in interface Ehcachepublic boolean isElementInMemory(Object arg0)
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(Serializable arg0)
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(Object arg0)
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(Serializable arg0)
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 String getGuid()
public CacheManager getCacheManager()
getCacheManager in interface Ehcachepublic void clearStatistics()
clearStatistics in interface Ehcachepublic int getStatisticsAccuracy()
getStatisticsAccuracy in interface EhcacheStatistics.STATISTICS_ACCURACY_BEST_EFFORT, Statistics.STATISTICS_ACCURACY_GUARANTEED, Statistics.STATISTICS_ACCURACY_NONEpublic void setStatisticsAccuracy(int arg0)
setStatisticsAccuracy in interface Ehcachearg0 - one of Statistics.STATISTICS_ACCURACY_BEST_EFFORT, Statistics.STATISTICS_ACCURACY_GUARANTEED, Statistics.STATISTICS_ACCURACY_NONEpublic void evictExpiredElements()
evictExpiredElements in interface Ehcachepublic boolean isKeyInCache(Object arg0)
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 Ehcachearg0 - the key to check forpublic boolean isValueInCache(Object arg0)
isValueInCache in interface Ehcachearg0 - to check forpublic Statistics getStatistics() throws 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 EhcacheIllegalStateException - if the cache is not Status.STATUS_ALIVEpublic LiveCacheStatistics getLiveCacheStatistics() throws 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 cacheIllegalStateExceptionpublic void registerCacheUsageListener(CacheUsageListener arg0) throws 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 checkregisterCacheUsageListener in interface EhcacheIllegalStateExceptionpublic void removeCacheUsageListener(CacheUsageListener arg0) throws IllegalStateException
CacheUsageListener, if any.
Depends on the Object.equals(Object) method.removeCacheUsageListener in interface EhcacheIllegalStateExceptionpublic void setCacheManager(CacheManager arg0)
setCacheManager in interface Ehcachearg0 - the CacheManager for this cache to use.public BootstrapCacheLoader getBootstrapCacheLoader()
getBootstrapCacheLoader in interface Ehcachepublic void setBootstrapCacheLoader(BootstrapCacheLoader arg0) throws CacheException
setBootstrapCacheLoader in interface Ehcachearg0 - the loader to be usedCacheException - if this method is called after the cache is initializedpublic void initialise()
MemoryStore or a DiskStore.
This method creates those and makes the cache ready to accept elementsinitialise in interface Ehcachepublic void bootstrap()
public CacheConfiguration getCacheConfiguration()
getCacheConfiguration in interface Ehcachepublic void registerCacheExtension(CacheExtension arg0)
CacheExtension with the cache. It will then be tied into the cache lifecycle.
If the CacheExtension is not initialised, initialise it.registerCacheExtension in interface Ehcachepublic void unregisterCacheExtension(CacheExtension arg0)
CacheExtension with the cache. It will then be detached from the cache lifecycle.unregisterCacheExtension in interface Ehcachepublic List getRegisteredCacheExtensions()
getRegisteredCacheExtensions in interface Ehcachepublic float getAverageGetTime()
getAverageGetTime in interface Ehcachepublic void setCacheExceptionHandler(CacheExceptionHandler arg0)
setCacheExceptionHandler in interface Ehcachepublic CacheExceptionHandler getCacheExceptionHandler()
getCacheExceptionHandler in interface Ehcachepublic void registerCacheLoader(CacheLoader arg0)
CacheLoader with the cache. It will then be tied into the cache lifecycle.
The CacheLoader instance will be initialized when the cache itself is being initialized.
Should the cache already be initialized, CacheLoader.init() will not be invoked.
If the loader requires initialization, the user will have to call it manually before registering it with a Cache instance
that's already aliveregisterCacheLoader in interface Ehcachearg0 - A Cache Loader to registerpublic void unregisterCacheLoader(CacheLoader arg0)
CacheLoader with the cache. It will then be detached from the cache lifecycle.unregisterCacheLoader in interface Ehcachearg0 - A Cache Loader to unregisterpublic List getRegisteredCacheLoaders()
getRegisteredCacheLoaders in interface Ehcachepublic void registerCacheWriter(CacheWriter arg0)
CacheWriter for this cache. It will then be tied into the cache lifecycle.
If the CacheWriter is not initialised, initialise it.registerCacheWriter in interface Ehcachearg0 - A CacheWriter to registerpublic void registerDynamicAttributesExtractor(DynamicAttributesExtractor extractor)
registerDynamicAttributesExtractor 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 Ehcachepublic CacheWriter getRegisteredCacheWriter()
CacheWriter that was registered for this cache.getRegisteredCacheWriter in interface EhcacheCacheWriter; or null if none was registered beforepublic Element getWithLoader(Object arg0, CacheLoader arg1, Object arg2) throws CacheException
getWithLoader in interface Ehcachearg0 - key whose associated value is to be returned.arg1 - the override loader to use. If null, the cache's default loader will be usedarg2 - an argument to pass to the CacheLoader.CacheExceptionpublic Map getAllWithLoader(Collection arg0, Object arg1) throws CacheException
SelfPopulatingCachegetAllWithLoader in interface Ehcachearg0 - a collection of keys to be returned/loadedarg1 - an argument to pass to the CacheLoader.CacheExceptionpublic boolean isDisabled()
Ehcache.setDisabled(boolean) method.
isDisabled in interface Ehcachepublic void setDisabled(boolean arg0)
setDisabled in interface Ehcachearg0 - true if you wish to disable, false to enableEhcache.isDisabled()public boolean isStatisticsEnabled()
isStatisticsEnabled in interface Ehcachepublic void setStatisticsEnabled(boolean arg0)
Ehcache.setSampledStatisticsEnabled(boolean) with
parameter true.
Disabling statistics also disables the sampled statistics collection if
it is enabledsetStatisticsEnabled in interface Ehcachepublic SampledCacheStatistics getSampledCacheStatistics()
getSampledCacheStatistics in interface Ehcachepublic void setSampledStatisticsEnabled(boolean arg0)
setSampledStatisticsEnabled in interface Ehcachepublic boolean isSampledStatisticsEnabled()
isSampledStatisticsEnabled in interface Ehcachepublic Object getInternalContext()
getInternalContext 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 Ehcachepublic CacheWriterManager getWriterManager()
getWriterManager in interface Ehcachepublic boolean isClusterCoherent()
throws TerracottaNotRunningException
isClusterCoherent in interface EhcacheTerracottaNotRunningExceptionpublic boolean isNodeCoherent()
throws TerracottaNotRunningException
isNodeCoherent in interface EhcacheTerracottaNotRunningExceptionpublic void setNodeCoherent(boolean arg0)
throws UnsupportedOperationException,
TerracottaNotRunningException
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 Ehcachearg0 - true transitions to coherent mode, false to incoherent modeUnsupportedOperationException - if this cache does not support coherence, like RMI replicationTerracottaNotRunningExceptionpublic void waitUntilClusterCoherent()
throws UnsupportedOperationException,
TerracottaNotRunningException
waitUntilClusterCoherent in interface EhcacheUnsupportedOperationException - if this cache does not support coherence, like RMI replicationTerracottaNotRunningExceptionpublic void setTransactionManagerLookup(TransactionManagerLookup arg0)
setTransactionManagerLookup in interface Ehcachepublic Attribute getSearchAttribute(String arg0) throws CacheException
getSearchAttribute in interface Ehcachearg0 - the name of the attribute to retrieveCacheException - if no such attribute is defined for the given namepublic Query createQuery()
createQuery in interface Ehcachepublic boolean isSearchable()
isSearchable in interface Ehcachepublic long getAverageSearchTime()
getAverageSearchTime in interface Ehcachepublic long getSearchesPerSecond()
getSearchesPerSecond in interface Ehcachepublic void acquireReadLockOnKey(Object arg0)
acquireReadLockOnKey in interface Ehcachearg0 - - The key that retrieves a value that you want to protect via lockingpublic void acquireWriteLockOnKey(Object arg0)
acquireWriteLockOnKey in interface Ehcachearg0 - - The key that retrieves a value that you want to protect via lockingpublic boolean tryReadLockOnKey(Object arg0, long arg1) throws InterruptedException
tryReadLockOnKey in interface Ehcachearg0 - - The key that retrieves a value that you want to protect via lockingarg1 - - millis until giveup on getting the lockInterruptedExceptionpublic boolean tryWriteLockOnKey(Object arg0, long arg1) throws InterruptedException
tryWriteLockOnKey in interface Ehcachearg0 - - The key that retrieves a value that you want to protect via lockingarg1 - - millis until giveup on getting the lockInterruptedExceptionpublic void releaseReadLockOnKey(Object arg0)
releaseReadLockOnKey in interface Ehcachearg0 - - The key that retrieves a value that you want to protect via lockingpublic void releaseWriteLockOnKey(Object arg0)
releaseWriteLockOnKey in interface Ehcachearg0 - - The key that retrieves a value that you want to protect via lockingpublic boolean isReadLockedByCurrentThread(Object arg0) throws UnsupportedOperationException
isReadLockedByCurrentThread in interface EhcacheUnsupportedOperationException - if querying the read lock state is not supportedpublic boolean isWriteLockedByCurrentThread(Object arg0) throws UnsupportedOperationException
isWriteLockedByCurrentThread in interface EhcacheUnsupportedOperationException - if querying the write lock state is not supportedpublic boolean isClusterBulkLoadEnabled()
throws UnsupportedOperationException,
TerracottaNotRunningException
Ehcache.isNodeBulkLoadEnabled() returns true, this method will always return true.
Applies to caches clustered with Terracotta only.isClusterBulkLoadEnabled in interface EhcacheUnsupportedOperationException - if the cache is not clustered with TerracottaTerracottaNotRunningExceptionpublic boolean isNodeBulkLoadEnabled()
throws UnsupportedOperationException,
TerracottaNotRunningException
Ehcache.isClusterBulkLoadEnabled() method will always return true.
Applies to caches clustered with Terracotta only.isNodeBulkLoadEnabled in interface EhcacheUnsupportedOperationException - if the cache is not clustered with TerracottaTerracottaNotRunningExceptionpublic void setNodeBulkLoadEnabled(boolean arg0)
throws 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 Ehcachearg0 - true enables bulk-load, false disables it if not already disabledUnsupportedOperationException - if the cache is not clustered with TerracottaTerracottaNotRunningExceptionpublic void waitUntilClusterBulkLoadComplete()
throws UnsupportedOperationException,
TerracottaNotRunningException
waitUntilClusterBulkLoadComplete in interface EhcacheUnsupportedOperationException - if the cache is not clustered with TerracottaTerracottaNotRunningExceptionpublic void loadAll(Collection arg0, Object arg1) throws CacheException
SelfPopulatingCacheloadAll in interface EhcacheCacheExceptionpublic boolean isPinned(Object arg0)
public void setPinned(Object arg0, boolean arg1)
Ehcache.replace(net.sf.ehcache.Element, net.sf.ehcache.Element) and Ehcache.remove(java.io.Serializable) does not change the pin state of key. This
comes with little memory overhead that even if key is removed, it is still held in memory.public String toString()
public Element get(Object arg0) throws IllegalStateException, CacheException
Ehcache.getQuiet(Object) to peek into the Element to see its last access time with getget in interface Ehcachearg0 - an Object valueIllegalStateException - if the cache is not Status.STATUS_ALIVECacheExceptionEhcache.isExpired(net.sf.ehcache.Element)public Element get(Serializable arg0) throws IllegalStateException, CacheException
Ehcache.getQuiet(Object) to peak into the Element to see its last access time with getget in interface Ehcachearg0 - a serializable valueIllegalStateException - if the cache is not Status.STATUS_ALIVECacheExceptionEhcache.isExpired(net.sf.ehcache.Element)public void put(Element arg0) throws IllegalArgumentException, IllegalStateException, CacheException
put in interface Ehcachearg0 - An object. If Serializable it can fully participate in replication and the DiskStore.IllegalArgumentException - if the element is nullIllegalStateException - if the cache is not Status.STATUS_ALIVECacheExceptionpublic void put(Element arg0, boolean arg1) throws IllegalArgumentException, IllegalStateException, CacheException
put in interface Ehcachearg0 - An object. If Serializable it can fully participate in replication and the DiskStore.arg1 - whether the put is coming from a doNotNotifyCacheReplicators cache peer, in which case this put should not initiate a
further notification to doNotNotifyCacheReplicators cache peersIllegalArgumentException - if the element is nullIllegalStateException - if the cache is not Status.STATUS_ALIVECacheExceptionpublic Object clone() throws CloneNotSupportedException
MemoryStore or DiskStore has been created.
A new, empty, RegisteredEventListeners is created on clone.
public Element replace(Element arg0) throws NullPointerException
replace in interface Ehcachearg0 - Element to be cachedNullPointerException - if the Element is null or has a null keypublic boolean replace(Element arg0, Element arg1) throws NullPointerException, IllegalArgumentException
replace in interface Ehcachearg0 - Element to be test againstarg1 - Element to be cachedNullPointerException - if the either Element is null or has a null keyIllegalArgumentException - if the two Element keys are non-null but not equalpublic void putAll(Collection arg0) throws IllegalArgumentException, IllegalStateException, CacheException
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 CacheEventListeners are notified of a newly put item
(notifyElementPut(...))
regardless of whether the individual put is a new put or an update.
putAll in interface Ehcachearg0 - the collection of elements to be put in the cache.IllegalStateException - if the cache is not Status.STATUS_ALIVECacheExceptionIllegalArgumentExceptionpublic boolean remove(Serializable arg0, boolean arg1) throws 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 Ehcachearg1 - whether the put is coming from a doNotNotifyCacheReplicators cache peer, in which case this put should not initiate a
further notification to doNotNotifyCacheReplicators cache peersIllegalStateException - if the cache is not Status.STATUS_ALIVEpublic boolean remove(Object arg0) throws 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 EhcacheIllegalStateException - if the cache is not Status.STATUS_ALIVEpublic boolean remove(Serializable arg0) throws 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 EhcacheIllegalStateException - if the cache is not Status.STATUS_ALIVEpublic boolean remove(Object arg0, boolean arg1) throws 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 Ehcachearg1 - whether the put is coming from a doNotNotifyCacheReplicators cache peer, in which case this put should not initiate a
further notification to doNotNotifyCacheReplicators cache peersIllegalStateException - if the cache is not Status.STATUS_ALIVEpublic void load(Object arg0) throws CacheException
SelfPopulatingCacheload in interface Ehcachearg0 - key whose associated value to be loaded using the associated cacheloader if this cache doesn't contain it.CacheExceptionpublic void setName(String arg0)
public void flush()
throws IllegalStateException,
CacheException
flush in interface EhcacheIllegalStateException - if the cache is not Status.STATUS_ALIVECacheExceptionpublic int getSize()
throws 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 EhcacheIllegalStateException - if the cache is not Status.STATUS_ALIVECacheExceptionpublic boolean removeElement(Element arg0) throws NullPointerException
removeElement in interface Ehcachearg0 - Element to be removedNullPointerException - if the element is null, or has a null keypublic void removeAll(boolean arg0)
throws IllegalStateException,
CacheException
NonstopConfiguration.getBulkOpsTimeoutMultiplyFactor() times the timeout value in the nonstop config.removeAll in interface Ehcachearg0 - whether the put is coming from a doNotNotifyCacheReplicators cache peer,
in which case this put should not initiate a further notification to doNotNotifyCacheReplicators cache peersIllegalStateException - if the cache is not Status.STATUS_ALIVECacheExceptionpublic void removeAll()
throws IllegalStateException,
CacheException
NonstopConfiguration.getBulkOpsTimeoutMultiplyFactor() times the timeout value in the nonstop config.removeAll in interface EhcacheIllegalStateException - if the cache is not Status.STATUS_ALIVECacheExceptionpublic void removeAll(Collection arg0, boolean arg1) throws IllegalStateException, NullPointerException
NonstopConfiguration.getBulkOpsTimeoutMultiplyFactor() times the timeout value in the nonstop config.removeAll in interface Ehcachearg1 - whether the put is coming from a doNotNotifyCacheReplicators cache peer,
in which case this put should not initiate a further notification to doNotNotifyCacheReplicators cache peersIllegalStateException - if the cache is not Status.STATUS_ALIVENullPointerExceptionpublic void removeAll(Collection arg0) throws IllegalStateException, NullPointerException
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 nullremoveAll in interface Ehcachearg0 - a collection of keys to operate onIllegalStateException - if the cache is not Status.STATUS_ALIVENullPointerException - if any key is null in the collectionpublic Element putIfAbsent(Element arg0) throws NullPointerException
putIfAbsent in interface Ehcachearg0 - element to be addedNullPointerException - if the element is null, or has a null keypublic Element putIfAbsent(Element arg0, boolean arg1) throws NullPointerException
putIfAbsent in interface Ehcachearg0 - element to be addedarg1 - whether the put is coming from a doNotNotifyCacheReplicators cache peer, in which case this put should not initiate a
further notification to doNotNotifyCacheReplicators cache peersNullPointerException - if the element is null, or has a null keypublic void addPropertyChangeListener(PropertyChangeListener arg0)
addPropertyChangeListener in interface Ehcachepublic void removePropertyChangeListener(PropertyChangeListener arg0)
removePropertyChangeListener in interface Ehcachepublic void dispose()
throws IllegalStateException
dispose in interface EhcacheIllegalStateException - if the cache is not Status.STATUS_ALIVEpublic List getKeys() throws IllegalStateException, CacheException
getKeys in interface EhcacheObject keysIllegalStateException - if the cache is not Status.STATUS_ALIVECacheExceptionCopyright © 2003-2014 Terracotta, Inc.. All Rights Reserved.