net.sf.ehcache
public final class Cache extends Object implements Cloneable
Version: $Id: Cache.java 52 2006-04-24 14:50:03Z gregluck $
Field Summary | |
---|---|
static String | DEFAULT_CACHE_NAME
A reserved word for cache names. |
static long | DEFAULT_EXPIRY_THREAD_INTERVAL_SECONDS
The default interval between runs of the expiry thread. |
static String | NET_SF_EHCACHE_DISABLED
System Property based method of disabling ehcache. |
Constructor Summary | |
---|---|
Cache(String name, int maxElementsInMemory, boolean overflowToDisk, boolean eternal, long timeToLiveSeconds, long timeToIdleSeconds)
1.0 Constructor.
| |
Cache(String name, int maxElementsInMemory, boolean overflowToDisk, boolean eternal, long timeToLiveSeconds, long timeToIdleSeconds, boolean diskPersistent, long diskExpiryThreadIntervalSeconds)
1.1 Constructor.
| |
Cache(String name, int maxElementsInMemory, MemoryStoreEvictionPolicy memoryStoreEvictionPolicy, boolean overflowToDisk, String diskStorePath, boolean eternal, long timeToLiveSeconds, long timeToIdleSeconds, boolean diskPersistent, long diskExpiryThreadIntervalSeconds, RegisteredEventListeners registeredEventListeners)
1.2 Constructor
The ConfigurationFactory and clients can create these.
|
Method Summary | |
---|---|
long | calculateInMemorySize()
Gets the size of the memory store for this cache
Warning: This method can be very expensive to run. |
Object | clone()
Clones a cache. |
void | dispose()
Flushes all cache items from memory to auxilliary caches and close the auxilliary caches.
|
void | flush()
Flushes all cache items from memory to the disk store, and from the DiskStore to disk.
|
Element | get(Serializable key)
Gets an element from the cache. |
Element | get(Object key)
Gets an element from the cache. |
RegisteredEventListeners | getCacheEventNotificationService()
Use this to access the service in order to register and unregister listeners
|
CacheManager | getCacheManager()
Gets the CacheManager managing this cache. |
long | getDiskExpiryThreadIntervalSeconds() |
DiskStore | getDiskStore()
Gets the internal DiskStore.
|
int | getDiskStoreHitCount()
Number of times a requested item was found in the Disk Store.
|
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.
|
int | getHitCount()
The number of times a requested item was found in the cache.
|
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. |
int | getMaxElementsInMemory()
Gets the maximum number of elements to hold in memory. |
MemoryStore | getMemoryStore()
Gets the internal MemoryStore.
|
MemoryStoreEvictionPolicy | getMemoryStoreEvictionPolicy()
The policy used to evict elements from the MemoryStore.
|
int | getMemoryStoreHitCount()
Number of times a requested item was found in the Memory Store.
|
long | getMemoryStoreSize()
Returns the number of elements in the memory store.
|
int | getMissCountExpired()
Number of times a requested element was found but was expired.
|
int | getMissCountNotFound()
Number of times a requested element was not found in the cache. |
String | getName()
Gets the cache name. |
Element | getQuiet(Serializable key)
Gets an element from the cache, without updating Element statistics. |
Element | getQuiet(Object key)
Gets an element from the cache, without updating Element statistics. |
int | getSize()
Gets the size of the cache. |
Status | getStatus()
Gets the status attribute of the Cache.
|
long | getTimeToIdleSeconds()
Gets timeToIdleSeconds. |
long | getTimeToLiveSeconds()
Gets timeToLiveSeconds. |
void | initialise()
Newly created caches do not have a MemoryStore or a DiskStore.
|
boolean | isDiskPersistent() |
boolean | isElementInMemory(Serializable key)
Whether an Element is stored in the cache in Memory, indicating a very low cost of retrieval.
|
boolean | isElementInMemory(Object key)
Whether an Element is stored in the cache in Memory, indicating a very low cost of retrieval.
|
boolean | isElementOnDisk(Serializable key)
Whether an Element is stored in the cache on Disk, indicating a higher cost of retrieval.
|
boolean | isElementOnDisk(Object key)
Whether an Element is stored in the cache on Disk, indicating a higher cost of retrieval.
|
boolean | isEternal()
Are elements eternal. |
boolean | isExpired(Element element)
Checks whether this cache element has expired.
|
boolean | isOverflowToDisk()
Does the overflow go to disk. |
void | put(Element element)
Put an element in the cache.
|
void | put(Element element, boolean doNotNotifyCacheReplicators)
Put an element in the cache.
|
void | putQuiet(Element element)
Put an element in the cache, without updating statistics, or updating listeners. |
boolean | remove(Serializable key)
Removes an Element from the Cache. |
boolean | remove(Object key)
Removes an Element from the Cache. |
boolean | remove(Serializable key, boolean doNotNotifyCacheReplicators)
Removes an Element from the Cache. |
boolean | remove(Object key, boolean doNotNotifyCacheReplicators)
Removes an Element from the Cache. |
void | removeAll()
Removes all cached items.
|
boolean | removeQuiet(Serializable key)
Removes an Element from the Cache, without notifying listeners. |
boolean | removeQuiet(Object key)
Removes an Element from the Cache, without notifying listeners. |
void | setCacheManager(CacheManager cacheManager)
Package local setter for use by CacheManager
|
void | setName(String name)
Sets the cache name which will name.
|
String | toString()
Returns a String representation of Cache. |
java -Dnet.sf.ehcache.disabled=true
in the command line.Parameters: name Cache name maxElementsInMemory Max elements in memory overflowToDisk Overflow to disk (boolean) eternal Whether the elements expire timeToLiveSeconds timeToIdleSeconds
Since: 1.0
Parameters: name maxElementsInMemory overflowToDisk eternal timeToLiveSeconds timeToIdleSeconds diskPersistent diskExpiryThreadIntervalSeconds
Since: 1.1
Parameters: name maxElementsInMemory memoryStoreEvictionPolicy one of LRU, LFU and FIFO. Optionally null, in which case it will be set to LRU. overflowToDisk diskStorePath eternal timeToLiveSeconds timeToIdleSeconds diskPersistent diskExpiryThreadIntervalSeconds registeredEventListeners a notification service. Optionally null, in which case a new one with no registered listeners will be created.
Since: 1.2
Returns: the approximate size of the memory store in bytes
Throws: IllegalStateException
Returns: an object of type Cache
Throws: CloneNotSupportedException
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Parameters: key a serializable value
Returns: the element, or null, if it does not exist.
Throws: IllegalStateException if the cache is not STATUS_ALIVE
See Also: Cache
Parameters: key an Object value
Returns: the element, or null, if it does not exist.
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Since: 1.2
See Also: Cache
Returns: the RegisteredEventListeners instance for this cache.
Returns: the manager or null if there is none
Returns: the interval between runs of the expiry thread, where it checks the disk store for expired elements. It is not the the timeToLiveSeconds.
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Returns: the number of elements in the disk store.
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Returns: the globally unique identifier for this cache instance. This is guaranteed to be unique.
Since: 1.2
Returns: the number of times a requested item was found in the cache
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Returns: a list of Object keys
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Returns: a list of Object keys
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Returns: a list of Object keys
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Since: 1.2
Returns: Number of times a requested item was found in the Memory Store.
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Returns: the number of elements in the memory store
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Parameters: key a serializable value
Returns: the element, or null, if it does not exist.
Throws: IllegalStateException if the cache is not STATUS_ALIVE
See Also: Cache
Parameters: key a serializable value
Returns: the element, or null, if it does not exist.
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Since: 1.2
See Also: Cache
Returns: The size value
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Returns: The status value from the Status enum class
Returns: true if the cache overflows to disk and the disk is persistent between restarts
Returns: true if an element matching the key is found in memory
Returns: true if an element matching the key is found in memory
Since: 1.2
Returns: true if an element matching the key is found in the diskStore
Returns: true if an element matching the key is found in the diskStore
Since: 1.2
Returns: true if it has expired
Throws: IllegalStateException if the cache is not STATUS_ALIVE NullPointerException if the element is null
Parameters: element An object. If Serializable it can fully participate in replication and the DiskStore.
Throws: IllegalStateException if the cache is not STATUS_ALIVE IllegalArgumentException if the element is null
Parameters: 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
Throws: IllegalStateException if the cache is not STATUS_ALIVE IllegalArgumentException if the element is null
Parameters: element An object. If Serializable it can fully participate in replication and the DiskStore.
Throws: IllegalStateException if the cache is not STATUS_ALIVE IllegalArgumentException if the element is null
Parameters: key
Returns: true if the element was removed, false if it was not found in the cache
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Parameters: key
Returns: true if the element was removed, false if it was not found in the cache
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Since: 1.2
Parameters: 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
Returns: true if the element was removed, false if it was not found in the cache
Throws: IllegalStateException if the cache is not STATUS_ALIVE
UNKNOWN: SameParameterValue
Parameters: 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
Returns: true if the element was removed, false if it was not found in the cache
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Parameters: key
Returns: true if the element was removed, false if it was not found in the cache
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Parameters: key
Returns: true if the element was removed, false if it was not found in the cache
Throws: IllegalStateException if the cache is not STATUS_ALIVE
Since: 1.2
Parameters: cacheManager
Parameters: name the name of the cache. Should not be null.