|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Ehcache
An interface for Ehcache.
Ehcache is the central interface. Caches haveElement
s and are managed
by the CacheManager
. The Cache performs logical actions. It delegates physical
implementations to its Store
s.
A reference to an EhCache can be obtained through the CacheManager
. An Ehcache thus obtained
is guaranteed to have status Status.STATUS_ALIVE
. This status is checked for any method which
throws IllegalStateException
and the same thrown if it is not alive. This would normally
happen if a call is made after CacheManager.shutdown()
is invoked.
Statistics on cache usage are collected and made available through public methods.
Method Summary | ||
---|---|---|
void |
acquireReadLockOnKey(Object key)
Acquires the proper read lock for a given cache key |
|
void |
acquireWriteLockOnKey(Object key)
Acquires the proper write lock for a given cache key |
|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener. |
|
void |
bootstrap()
Bootstrap command. |
|
long |
calculateInMemorySize()
Deprecated. |
|
long |
calculateOffHeapSize()
Deprecated. |
|
long |
calculateOnDiskSize()
Deprecated. |
|
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 key)
Gets an element from the cache. |
|
Element |
get(Serializable key)
Gets an element from the cache. |
|
Map<Object,Element> |
getAll(Collection<?> keys)
Gets all the elements from the cache for the keys provided. |
|
Map |
getAllWithLoader(Collection keys,
Object loaderArgument)
The getAll method will return, from the cache, a Map of the objects associated with the Collection of keys in argument "keys". |
|
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()
Deprecated. |
|
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()
Deprecated. versions since 2.1 do not return duplicates |
|
List |
getKeysWithExpiryCheck()
Returns a list of all elements in the cache. |
|
long |
getMemoryStoreSize()
Deprecated. |
|
String |
getName()
Gets the cache name. |
|
long |
getOffHeapStoreSize()
Deprecated. |
|
Element |
getQuiet(Object key)
Gets an element from the cache, without updating Element statistics. |
|
Element |
getQuiet(Serializable key)
Gets an element from the cache, without updating Element statistics. |
|
List<CacheExtension> |
getRegisteredCacheExtensions()
|
|
List<CacheLoader> |
getRegisteredCacheLoaders()
|
|
CacheWriter |
getRegisteredCacheWriter()
Retrieves the CacheWriter that was registered for this cache. |
|
|
getSearchAttribute(String attributeName)
Retrieve the given named search attribute |
|
int |
getSize()
Gets the size of the cache. |
|
StatisticsGateway |
getStatistics()
Gets an immutable Statistics object representing the Cache statistics at the time. |
|
Status |
getStatus()
Gets the status attribute of the Cache. |
|
Element |
getWithLoader(Object key,
CacheLoader loader,
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. |
|
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()
Deprecated. Use isClusterBulkLoadEnabled() instead |
|
boolean |
isDisabled()
Whether this cache is disabled. |
|
boolean |
isElementInMemory(Object key)
Whether an Element is stored in the cache in Memory, indicating a very low cost of retrieval. |
|
boolean |
isElementInMemory(Serializable key)
Whether an Element is stored in the cache in Memory, indicating a very low cost of retrieval. |
|
boolean |
isElementOnDisk(Object key)
Whether an Element is stored in the cache on Disk, indicating a higher cost of retrieval. |
|
boolean |
isElementOnDisk(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(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(Object key)
Returns true if a read lock for the key is held by the current thread |
|
boolean |
isSearchable()
Is this cache searchable? |
|
boolean |
isValueInCache(Object value)
An extremely expensive check to see if the value exists in the cache. |
|
boolean |
isWriteLockedByCurrentThread(Object key)
Returns true if a write lock for the key is held by the current thread |
|
void |
load(Object key)
The load method provides a means to "pre load" the cache. |
|
void |
loadAll(Collection keys,
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. |
|
void |
putAll(Collection<Element> elements)
Puts a collection of elements in to the cache. |
|
Element |
putIfAbsent(Element element)
Put an element in the cache if no element is currently mapped to the elements key. |
|
Element |
putIfAbsent(Element element,
boolean doNotNotifyCacheReplicators)
Put an element in the cache if no element is currently mapped to the elements key. |
|
void |
putQuiet(Element element)
Put an element in the cache, without updating statistics, or updating listeners. |
|
void |
putWithWriter(Element element)
Put an element in the cache writing through a CacheWriter. |
|
void |
registerCacheExtension(CacheExtension cacheExtension)
Register a CacheExtension with the cache. |
|
void |
registerCacheLoader(CacheLoader cacheLoader)
Register a CacheLoader with the cache. |
|
void |
registerCacheWriter(CacheWriter cacheWriter)
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 key)
Release a held read lock for the passed in key |
|
void |
releaseWriteLockOnKey(Object key)
Release a held write lock for the passed in key |
|
boolean |
remove(Object key)
Removes an Element from the Cache. |
|
boolean |
remove(Object key,
boolean doNotNotifyCacheReplicators)
Removes an Element from the Cache. |
|
boolean |
remove(Serializable key)
Removes an Element from the Cache. |
|
boolean |
remove(Serializable key,
boolean doNotNotifyCacheReplicators)
Removes an Element from the Cache. |
|
void |
removeAll()
Removes all cached items. |
|
void |
removeAll(boolean doNotNotifyCacheReplicators)
Removes all cached items. |
|
void |
removeAll(Collection<?> keys)
Removes given set of Element from the Cache. |
|
void |
removeAll(Collection<?> keys,
boolean doNotNotifyCacheReplicators)
Removes all cached items. |
|
boolean |
removeElement(Element element)
Remove the Element mapped to the key for the supplied element if the value of the supplied Element compares equal to the value of the cached Element. |
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener. |
|
boolean |
removeQuiet(Object key)
Removes an Element from the Cache, without notifying listeners. |
|
boolean |
removeQuiet(Serializable key)
Removes an Element from the Cache, without notifying listeners. |
|
boolean |
removeWithWriter(Object key)
Removes an Element from the Cache and any stores it might be in. |
|
Element |
replace(Element element)
Replace the cached element only if an Element is currently cached for this key |
|
boolean |
replace(Element old,
Element element)
Replace the cached element only if the current Element is equal to the supplied old Element. |
|
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 |
setName(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 |
setTransactionManagerLookup(TransactionManagerLookup transactionManagerLookup)
This class is used to access the transaction manager used during XA. |
|
String |
toString()
Returns a String representation of Cache . |
|
boolean |
tryReadLockOnKey(Object key,
long timeout)
Try to get a read lock on a given key. |
|
boolean |
tryWriteLockOnKey(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 |
Method Detail |
---|
void put(Element element) throws IllegalArgumentException, IllegalStateException, CacheException
element
- An object. If Serializable it can fully participate in replication and the DiskStore.
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
IllegalArgumentException
- if the element is null
CacheException
void putAll(Collection<Element> elements) 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 CacheEventListener
s are notified of a newly put item
(notifyElementPut(...)
)
regardless of whether the individual put is a new put or an update.
elements
- the collection of elements to be put in the cache.
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
IllegalArgumentException
void put(Element element, boolean doNotNotifyCacheReplicators) throws IllegalArgumentException, IllegalStateException, CacheException
element
- An object. If Serializable it can fully participate in replication and the DiskStore.doNotNotifyCacheReplicators
- whether the put is coming from a doNotNotifyCacheReplicators cache peer, in which case this put should not initiate a
further notification to doNotNotifyCacheReplicators cache peers
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
IllegalArgumentException
- if the element is null
CacheException
void putQuiet(Element element) throws IllegalArgumentException, IllegalStateException, CacheException
getQuiet(java.io.Serializable)
element
- An object. If Serializable it can fully participate in replication and the DiskStore.
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
IllegalArgumentException
- if the element is null
CacheException
void putWithWriter(Element element) throws IllegalArgumentException, IllegalStateException, CacheException
element
- An object. If Serializable it can fully participate in replication and the DiskStore.
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
IllegalArgumentException
- if the element is null
CacheException
- if no CacheWriter was registeredElement putIfAbsent(Element element) throws NullPointerException
element
- element to be added
NullPointerException
- if the element is null, or has a null keyElement putIfAbsent(Element element, boolean doNotNotifyCacheReplicators) throws NullPointerException
element
- element to be addeddoNotNotifyCacheReplicators
- whether the put is coming from a doNotNotifyCacheReplicators cache peer, in which case this put should not initiate a
further notification to doNotNotifyCacheReplicators cache peers
NullPointerException
- if the element is null, or has a null keyboolean removeElement(Element element) throws NullPointerException
This is equivalent to
if (elementValueComparator.equals(cache.get(element.getObjectKey()), element)) { return cache.remove(element.getObjectKey()); } else return false;except that the action is performed atomically.
element
- Element to be removed
true
if the value was removed
NullPointerException
- if the element is null, or has a null keyCacheConfiguration.addElementValueComparator(net.sf.ehcache.config.ElementValueComparatorConfiguration)
boolean replace(Element old, Element element) throws NullPointerException, IllegalArgumentException
old
- Element to be test againstelement
- Element to be cached
NullPointerException
- if the either Element is null or has a null key
IllegalArgumentException
- if the two Element keys are non-null but not equalElement replace(Element element) throws NullPointerException
element
- Element to be cached
NullPointerException
- if the Element is null or has a null keyElement get(Serializable key) throws IllegalStateException, CacheException
getQuiet(Object)
to peak into the Element to see its last access time with get
key
- a serializable value
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
isExpired(net.sf.ehcache.Element)
Element get(Object key) throws IllegalStateException, CacheException
getQuiet(Object)
to peek into the Element to see its last access time with get
key
- an Object value
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
isExpired(net.sf.ehcache.Element)
Map<Object,Element> getAll(Collection<?> keys) throws IllegalStateException, CacheException, NullPointerException
getQuiet(Object)
to peek into the Element to see its last access time with get
keys
- a collection of keys for which value is to be fetched
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
NullPointerException
- if any key is null in the collection
CacheException
isExpired(net.sf.ehcache.Element)
Element getQuiet(Serializable key) throws IllegalStateException, CacheException
key
- a serializable value
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
isExpired(net.sf.ehcache.Element)
Element getQuiet(Object key) throws IllegalStateException, CacheException
key
- a serializable value
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
isExpired(net.sf.ehcache.Element)
List getKeys() throws IllegalStateException, CacheException
Object
keys
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
List getKeysWithExpiryCheck() throws IllegalStateException, CacheException
Object
keys
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
@Deprecated List getKeysNoDuplicateCheck() throws IllegalStateException
Object
keys
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
boolean remove(Serializable key) 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.
key
-
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
boolean remove(Object key) 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.
key
-
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
void removeAll(Collection<?> keys) 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 null
keys
- a collection of keys to operate on
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
NullPointerException
- if any key is null in the collectionvoid removeAll(Collection<?> keys, boolean doNotNotifyCacheReplicators) throws IllegalStateException, NullPointerException
NonstopConfiguration.getBulkOpsTimeoutMultiplyFactor()
times the timeout value in the nonstop config.
doNotNotifyCacheReplicators
- whether the put is coming from a doNotNotifyCacheReplicators cache peer,
in which case this put should not initiate a further notification to doNotNotifyCacheReplicators cache peers
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
NullPointerException
boolean remove(Serializable key, boolean doNotNotifyCacheReplicators) 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.
key
- doNotNotifyCacheReplicators
- whether the put is coming from a doNotNotifyCacheReplicators cache peer, in which case this put should not initiate a
further notification to doNotNotifyCacheReplicators cache peers
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
boolean remove(Object key, boolean doNotNotifyCacheReplicators) 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.
key
- doNotNotifyCacheReplicators
- whether the put is coming from a doNotNotifyCacheReplicators cache peer, in which case this put should not initiate a
further notification to doNotNotifyCacheReplicators cache peers
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
boolean removeQuiet(Serializable key) throws IllegalStateException
Element
from the Cache, without notifying listeners. This also removes it from any
stores it may be in.
key
-
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
boolean removeQuiet(Object key) throws IllegalStateException
Element
from the Cache, without notifying listeners. This also removes it from any
stores it may be in.
key
-
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
boolean removeWithWriter(Object key) 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.
key
-
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
- if no CacheWriter was registeredvoid removeAll() throws IllegalStateException, CacheException
NonstopConfiguration.getBulkOpsTimeoutMultiplyFactor()
times the timeout value in the nonstop config.
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
void removeAll(boolean doNotNotifyCacheReplicators) throws IllegalStateException, CacheException
NonstopConfiguration.getBulkOpsTimeoutMultiplyFactor()
times the timeout value in the nonstop config.
doNotNotifyCacheReplicators
- whether the put is coming from a doNotNotifyCacheReplicators cache peer,
in which case this put should not initiate a further notification to doNotNotifyCacheReplicators cache peers
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
void flush() throws IllegalStateException, CacheException
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
int getSize() throws IllegalStateException, CacheException
Element
s in the MemoryStore
plus
the number of Element
s 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 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.
Note:getSize() is a very expensive operation in off-heap, disk and Terracotta implementations.
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheException
@Deprecated long calculateInMemorySize() throws IllegalStateException, CacheException
IllegalStateException
CacheException
@Deprecated long calculateOffHeapSize() throws IllegalStateException, CacheException
IllegalStateException
CacheException
@Deprecated long calculateOnDiskSize() throws IllegalStateException, CacheException
IllegalStateException
CacheException
boolean hasAbortedSizeOf()
@Deprecated long getMemoryStoreSize() throws IllegalStateException
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
@Deprecated long getOffHeapStoreSize() throws IllegalStateException
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
@Deprecated int getDiskStoreSize() throws IllegalStateException
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
Status getStatus()
String getName()
void setName(String name)
name
- the name of the cache. Should not be null.String toString()
String
representation of Cache
.
toString
in class Object
boolean isExpired(Element element) throws IllegalStateException, NullPointerException
element
- the element to check
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
NullPointerException
- if the element is nullObject clone() throws CloneNotSupportedException
MemoryStore
or DiskStore
has been created.
A new, empty, RegisteredEventListeners is created on clone.
Cache
CloneNotSupportedException
RegisteredEventListeners getCacheEventNotificationService()
boolean isElementInMemory(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.
boolean isElementInMemory(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.
boolean isElementOnDisk(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.
boolean isElementOnDisk(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.
String getGuid()
CacheManager getCacheManager()
void evictExpiredElements()
For large caches - or caches with high-latency storage this method can take a very long time to complete. You should seriously consider relying on some form of capacity eviction to control cache capacity over calling this method. As this method can take a long time the cache may not be fully purged of expired elements on return, since more elements may have expired during the call.
boolean isKeyInCache(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.
key
- the key to check for
boolean isValueInCache(Object value)
value
- to check for
StatisticsGateway getStatistics() throws IllegalStateException
Statistics#STATISTICS_ACCURACY_BEST_EFFORT
.
The size is the number of Element
s in the MemoryStore
plus
the number of Element
s 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.
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
void setCacheManager(CacheManager cacheManager)
cacheManager
- the CacheManager for this cache to use.BootstrapCacheLoader getBootstrapCacheLoader()
void setBootstrapCacheLoader(BootstrapCacheLoader bootstrapCacheLoader) throws CacheException
bootstrapCacheLoader
- the loader to be used
CacheException
- if this method is called after the cache is initializedvoid initialise()
MemoryStore
or a DiskStore
.
This method creates those and makes the cache ready to accept elements
void bootstrap()
void dispose() throws IllegalStateException
IllegalStateException
- if the cache is not Status.STATUS_ALIVE
CacheConfiguration getCacheConfiguration()
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.
void unregisterCacheExtension(CacheExtension cacheExtension)
CacheExtension
with the cache. It will then be detached from the cache lifecycle.
List<CacheExtension> getRegisteredCacheExtensions()
void setCacheExceptionHandler(CacheExceptionHandler cacheExceptionHandler)
CacheExceptionHandler getCacheExceptionHandler()
void registerCacheLoader(CacheLoader cacheLoader)
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 alive
cacheLoader
- A Cache Loader to registervoid unregisterCacheLoader(CacheLoader cacheLoader)
CacheLoader
with the cache. It will then be detached from the cache lifecycle.
cacheLoader
- A Cache Loader to unregisterList<CacheLoader> getRegisteredCacheLoaders()
void registerDynamicAttributesExtractor(DynamicAttributesExtractor extractor)
extractor
- 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.
cacheWriter
- A CacheWriter to registervoid 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.
CacheWriter getRegisteredCacheWriter()
CacheWriter
that was registered for this cache.
CacheWriter
; or null
if none was registered beforeElement getWithLoader(Object key, CacheLoader loader, Object loaderArgument) throws CacheException
key
- key whose associated value is to be returned.loader
- the override loader to use. If null, the cache's default loader will be usedloaderArgument
- an argument to pass to the CacheLoader.
CacheException
Map getAllWithLoader(Collection keys, Object loaderArgument) throws CacheException
SelfPopulatingCache
keys
- a collection of keys to be returned/loadedloaderArgument
- an argument to pass to the CacheLoader.
CacheException
void load(Object key) throws CacheException
SelfPopulatingCache
key
- key whose associated value to be loaded using the associated cacheloader if this cache doesn't contain it.
CacheException
void loadAll(Collection keys, Object argument) throws CacheException
SelfPopulatingCache
CacheException
boolean isDisabled()
setDisabled(boolean)
method.
void setDisabled(boolean disabled)
disabled
- true if you wish to disable, false to enableisDisabled()
Object getInternalContext()
void disableDynamicFeatures()
This is a one time operation. Once an Ehcache instance has had its dynamic operations disabled they cannot be re-enabled.
CacheWriterManager getWriterManager()
@Deprecated boolean isClusterCoherent() throws TerracottaNotRunningException
isClusterBulkLoadEnabled()
instead
TerracottaNotRunningException
@Deprecated boolean isNodeCoherent() throws TerracottaNotRunningException
isNodeBulkLoadEnabled()
instead
TerracottaNotRunningException
@Deprecated void setNodeCoherent(boolean coherent) throws UnsupportedOperationException, TerracottaNotRunningException
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.
coherent
- true transitions to coherent mode, false to incoherent mode
UnsupportedOperationException
- if this cache does not support coherence, like RMI replication
TerracottaNotRunningException
@Deprecated void waitUntilClusterCoherent() throws UnsupportedOperationException, TerracottaNotRunningException
waitUntilClusterBulkLoadComplete()
instead
UnsupportedOperationException
- if this cache does not support coherence, like RMI replication
TerracottaNotRunningException
void setTransactionManagerLookup(TransactionManagerLookup transactionManagerLookup)
transactionManagerLookup
- void addPropertyChangeListener(PropertyChangeListener listener)
listener
- void removePropertyChangeListener(PropertyChangeListener listener)
listener
- <T> Attribute<T> getSearchAttribute(String attributeName) throws CacheException
T
- type of the attributeattributeName
- the name of the attribute to retrieve
CacheException
- if no such attribute is defined for the given nameQuery createQuery()
boolean isSearchable()
void acquireReadLockOnKey(Object key)
key
- - The key that retrieves a value that you want to protect via lockingvoid acquireWriteLockOnKey(Object key)
key
- - The key that retrieves a value that you want to protect via lockingboolean tryReadLockOnKey(Object key, long timeout) throws InterruptedException
key
- - The key that retrieves a value that you want to protect via lockingtimeout
- - millis until giveup on getting the lock
InterruptedException
boolean tryWriteLockOnKey(Object key, long timeout) throws InterruptedException
key
- - The key that retrieves a value that you want to protect via lockingtimeout
- - millis until giveup on getting the lock
InterruptedException
void releaseReadLockOnKey(Object key)
key
- - The key that retrieves a value that you want to protect via lockingvoid releaseWriteLockOnKey(Object key)
key
- - The key that retrieves a value that you want to protect via lockingboolean isReadLockedByCurrentThread(Object key) throws UnsupportedOperationException
key
-
UnsupportedOperationException
- if querying the read lock state is not supportedboolean isWriteLockedByCurrentThread(Object key) throws UnsupportedOperationException
key
-
UnsupportedOperationException
- if querying the write lock state is not supportedboolean isClusterBulkLoadEnabled() throws UnsupportedOperationException, TerracottaNotRunningException
isNodeBulkLoadEnabled()
returns true, this method will always return true.
Applies to caches clustered with Terracotta only.
UnsupportedOperationException
- if the cache is not clustered with Terracotta
TerracottaNotRunningException
boolean isNodeBulkLoadEnabled() throws UnsupportedOperationException, TerracottaNotRunningException
isClusterBulkLoadEnabled()
method will always return true.
Applies to caches clustered with Terracotta only.
UnsupportedOperationException
- if the cache is not clustered with Terracotta
TerracottaNotRunningException
void setNodeBulkLoadEnabled(boolean enabledBulkLoad) 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.
enabledBulkLoad
- true enables bulk-load, false disables it if not already disabled
UnsupportedOperationException
- if the cache is not clustered with Terracotta
TerracottaNotRunningException
void waitUntilClusterBulkLoadComplete() throws UnsupportedOperationException, TerracottaNotRunningException
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 |