|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.ehcache.store.AbstractStore net.sf.ehcache.store.LruMemoryStore
public class LruMemoryStore
An implementation of a LruMemoryStore.
This usesLinkedHashMap
as its backing map. It uses the LinkedHashMap
LRU
feature. LRU for this implementation means least recently accessed.
Nested Class Summary | |
---|---|
class |
LruMemoryStore.SpoolingLinkedHashMap
An extension of LinkedHashMap which overrides LruMemoryStore.SpoolingLinkedHashMap.removeEldestEntry(java.util.Map.Entry)
to persist cache entries to the auxiliary cache before they are removed. |
Field Summary | |
---|---|
protected Ehcache |
cache
The cache this store is associated with. |
protected Store |
diskStore
The DiskStore associated with this MemoryStore. |
protected Map |
map
Map where items are stored by key. |
protected long |
maximumSize
The maximum size of the store (0 == no limit) |
protected Status |
status
status. |
Fields inherited from class net.sf.ehcache.store.AbstractStore |
---|
attributeExtractors |
Fields inherited from interface net.sf.ehcache.store.Store |
---|
CLUSTER_COHERENT, NODE_COHERENT |
Constructor Summary | |
---|---|
LruMemoryStore(Ehcache cache,
Store diskStore)
Constructor for the LruMemoryStore object The backing LinkedHashMap is created with LRU by access order. |
Method Summary | |
---|---|
boolean |
bufferFull()
Memory stores are never backed up and always return false |
protected void |
clear()
Clears any data structures and places it back to its state when it was first created. |
boolean |
containsKey(Object key)
An unsynchronized check to see if a key is in the Store. |
boolean |
containsKeyInMemory(Object key)
A check to see if a key is in the Store and is currently held in memory. |
boolean |
containsKeyOffHeap(Object key)
A check to see if a key is in the Store and is currently held off-heap. |
boolean |
containsKeyOnDisk(Object key)
A check to see if a key is in the Store and is currently held on disk. |
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 |
expireElements()
Expire all elsments. |
void |
flush()
Flush to disk only if the cache is diskPersistent. |
Element |
get(Object key)
Gets an item from the cache. |
Policy |
getEvictionPolicy()
|
Policy |
getInMemoryEvictionPolicy()
|
int |
getInMemorySize()
Returns the current local in-memory store size |
long |
getInMemorySizeInBytes()
Gets the size of the in-memory portion of the store, in bytes. |
Object |
getInternalContext()
This should not be used, and will generally return null |
List |
getKeys()
Gets an Array of the keys for all elements in the memory cache. |
Object |
getMBean()
Optional implementation specific MBean exposed by the store. |
int |
getOffHeapSize()
Returns the current local off-heap store size |
long |
getOffHeapSizeInBytes()
Gets the size of the off-heap portion of the store, in bytes. |
int |
getOnDiskSize()
Returns the current local on-disk store size |
long |
getOnDiskSizeInBytes()
Gets the size of the on-disk portion of the store, in bytes. |
Element |
getQuiet(Object key)
Gets an item from the cache, without updating statistics. |
int |
getSize()
Returns the current cache size. |
long |
getSizeInBytes()
Measures the size of the memory store by using the sizeof engine. |
Status |
getStatus()
Gets the status of the MemoryStore. |
int |
getTerracottaClusteredSize()
Returns nothing since a disk store isn't clustered |
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. |
boolean |
put(Element element)
Puts an item in the cache. |
Element |
putIfAbsent(Element element)
Unsupported in LruMemoryStore |
boolean |
putWithWriter(Element element,
CacheWriterManager writerManager)
Puts an item into the store and the cache writer manager in an atomic operation |
Element |
remove(Object key)
Removes an Element from the store. |
void |
removeAll()
Remove all of the elements from the store. |
Element |
removeElement(Element element,
ElementValueComparator comparator)
Unsupported in LruMemoryStore |
Element |
removeWithWriter(Object key,
CacheWriterManager writerManager)
Removes an item from the store and the cache writer manager in an atomic operation. |
Element |
replace(Element element)
Unsupported in LruMemoryStore |
boolean |
replace(Element old,
Element element,
ElementValueComparator comparator)
Unsupported in LruMemoryStore |
void |
setEvictionPolicy(Policy policy)
Sets the eviction policy strategy. |
void |
setInMemoryEvictionPolicy(Policy policy)
Sets the eviction policy strategy. |
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 net.sf.ehcache.store.AbstractStore |
---|
addStoreListener, executeQuery, getAll, getAllQuiet, getEventListenerList, getSearchAttribute, hasAbortedSizeOf, isCacheCoherent, isClusterCoherent, isNodeCoherent, putAll, recalculateSize, removeAll, removeStoreListener, setAttributeExtractors, setNodeCoherent, waitUntilClusterCoherent |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Ehcache cache
protected Map map
protected final Store diskStore
protected Status status
protected long maximumSize
Constructor Detail |
---|
public LruMemoryStore(Ehcache cache, Store diskStore)
LinkedHashMap
is created with LRU by access order.
Method Detail |
---|
public final boolean put(Element element) throws CacheException
LruMemoryStore.SpoolingLinkedHashMap.removeEldestEntry(java.util.Map.Entry)
being called.
element
- the element to add
CacheException
public final boolean putWithWriter(Element element, CacheWriterManager writerManager) throws CacheException
CacheException
protected void doPut(Element element) throws CacheException
element
-
CacheException
public final Element get(Object key)
Element
is updated.
key
- the cache key
public final Element getQuiet(Object key)
key
- the cache key
public final Element remove(Object key)
key
- the key of the Element, usually a String
public final Element removeWithWriter(Object key, CacheWriterManager writerManager) throws CacheException
CacheException
public final void removeAll() throws CacheException
CacheException
protected final void clear()
public final void dispose()
public final void flush()
protected final void spoolAllToDisk()
protected void spoolToDisk(Element element)
element
- The Elementpublic final Status getStatus()
public final List getKeys()
public final int getSize()
public final int getTerracottaClusteredSize()
public final boolean containsKey(Object key)
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()
public void expireElements()
public boolean bufferFull()
public Object getMBean()
public Policy getEvictionPolicy()
setEvictionPolicy(Policy)
public void setEvictionPolicy(Policy policy)
policy
- the new policypublic Object getInternalContext()
public boolean containsKeyInMemory(Object key)
key
- The Element key
public boolean containsKeyOffHeap(Object key)
key
- The Element key
public boolean containsKeyOnDisk(Object key)
key
- The Element key
public Policy getInMemoryEvictionPolicy()
Store.setInMemoryEvictionPolicy(Policy)
public int getInMemorySize()
public long getInMemorySizeInBytes()
public int getOffHeapSize()
public long getOffHeapSizeInBytes()
public int getOnDiskSize()
public long getOnDiskSizeInBytes()
public void setInMemoryEvictionPolicy(Policy policy)
policy
- the new policypublic Element putIfAbsent(Element element) throws NullPointerException
element
- element to be added
NullPointerException
- if the element is null, or has a null keypublic Element removeElement(Element element, ElementValueComparator comparator) throws NullPointerException
element
- Element to be removedcomparator
- ElementValueComparator to use to compare elements
NullPointerException
- if the element is null, or has a null keypublic boolean replace(Element old, Element element, ElementValueComparator comparator) throws NullPointerException, IllegalArgumentException
old
- Element to be test againstelement
- Element to be cachedcomparator
- ElementValueComparator to use to compare elements
NullPointerException
- if the either Element is null or has a null key
IllegalArgumentException
- if the two Element keys are non-null but not equalpublic Element replace(Element element) throws NullPointerException
element
- Element to be cached
NullPointerException
- if the Element is null or has a null key
|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |