|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.ehcache.store.MemoryStore
public abstract class MemoryStore
An abstract class for the Memory Stores. All Memory store implementations for different policies (e.g: FIFO, LFU, LRU, etc.) should extend this class.
Field Summary | |
---|---|
protected Ehcache |
cache
The cache this store is associated with. |
protected DiskStore |
diskStore
The DiskStore associated with this MemoryStore. |
protected java.util.Map |
map
Map where items are stored by key. |
protected Status |
status
status. |
Constructor Summary | |
---|---|
protected |
MemoryStore(Ehcache cache,
DiskStore diskStore)
Constructs things that all MemoryStores have in common. |
Method Summary | |
---|---|
protected void |
clear()
Clears any data structures and places it back to its state when it was first created. |
boolean |
containsKey(java.lang.Object key)
An unsynchronized check to see if a key is in the Store. |
static MemoryStore |
create(Ehcache cache,
DiskStore diskStore)
A factory method to create a MemoryStore. |
void |
dispose()
Prepares for shutdown. |
protected void |
doPut(Element element)
Allow specialised actions over adding the element to the map. |
protected void |
evict(Element element)
Evict the Element . |
void |
flush()
Flush to disk. |
Element |
get(java.lang.Object key)
Gets an item from the cache. |
java.lang.Object[] |
getKeyArray()
Gets an Array of the keys for all elements in the memory cache. |
Element |
getQuiet(java.lang.Object key)
Gets an item from the cache, without updating Element statistics. |
int |
getSize()
Returns the current cache size. |
long |
getSizeInBytes()
Measures the size of the memory store by measuring the serialized size of all elements. |
Status |
getStatus()
Gets the status of the MemoryStore. |
protected boolean |
isFull()
An algorithm to tell if the MemoryStore is at or beyond its carrying capacity. |
protected void |
notifyExpiry(Element element)
Before eviction elements are checked. |
void |
put(Element element)
Puts an item in the cache. |
Element |
remove(java.lang.Object key)
Removes an Element from the store. |
void |
removeAll()
Remove all of the elements from the store. |
protected void |
spoolAllToDisk()
Spools all elements to disk, in preparation for shutdown. |
protected void |
spoolToDisk(Element element)
Puts the element in the DiskStore. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Ehcache cache
protected java.util.Map map
protected final DiskStore diskStore
protected Status status
Constructor Detail |
---|
protected MemoryStore(Ehcache cache, DiskStore diskStore)
cache
- diskStore
- Method Detail |
---|
public static MemoryStore create(Ehcache cache, DiskStore diskStore)
cache
- diskStore
-
public final void put(Element element) throws CacheException
LruMemoryStore.SpoolingLinkedHashMap.removeEldestEntry(java.util.Map.Entry)
being called.
put
in interface Store
element
- the element to add
CacheException
protected void doPut(Element element) throws CacheException
element
-
CacheException
public final Element get(java.lang.Object key)
Element
is updated.
get
in interface Store
key
- the cache key
public final Element getQuiet(java.lang.Object key)
key
- the cache key
public final Element remove(java.lang.Object key)
remove
in interface Store
key
- the key of the Element, usually a String
public final void removeAll() throws CacheException
removeAll
in interface Store
CacheException
protected final void clear()
public final void dispose()
dispose
in interface Store
public final void flush()
protected final void spoolAllToDisk()
protected final void spoolToDisk(Element element)
Ehcache.isOverflowToDisk()
is true
Relies on being called from a synchronized method
element
- The Elementpublic final Status getStatus()
getStatus
in interface Store
public final java.lang.Object[] getKeyArray()
public final int getSize()
getSize
in interface Store
public final boolean containsKey(java.lang.Object key)
containsKey
in interface Store
key
- The Element key
public final long getSizeInBytes() throws CacheException
CacheException
protected final void evict(Element element) throws CacheException
Element
.
Evict means that the Element
is:
Element
is spooled to the DiskStore
Element
is removed.
element
- the Element
to be evicted.
CacheException
protected final void notifyExpiry(Element element)
element
- protected final boolean isFull()
|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |