|
ehcache | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.ehcache.store.AbstractStore
net.sf.ehcache.store.MemoryStore
public class MemoryStore
A Store implementation suitable for fast, concurrent in memory stores. The policy is determined by that configured in the cache.
| Nested Class Summary | |
|---|---|
protected static interface |
MemoryStore.BackingFactory
Factory interface to create a MemoryStore backing. |
| Field Summary |
|---|
| 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 | |
|---|---|
protected |
MemoryStore(Ehcache cache,
Pool pool,
boolean notify,
MemoryStore.BackingFactory factory)
Constructs things that all MemoryStores have in common. |
| Method Summary | |
|---|---|
boolean |
bufferFull()
Memory stores are never backed up and always return false |
boolean |
canPutWithoutEvicting(Element element)
Check if adding an element won't provoke an eviction. |
boolean |
containsKey(Object key)
A 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. |
static MemoryStore |
create(Ehcache cache,
Pool pool)
A factory method to create a MemoryStore. |
void |
deregistered(CacheConfiguration config)
Indicates that this listener was removed from the given configuration |
void |
diskCapacityChanged(int oldCapacity,
int newCapacity)
Indicates a change in the configurations disk store capacity |
void |
dispose()
Prepares for shutdown. |
Collection<Element> |
elementSet()
Get a collection of the elements in this store |
protected boolean |
evict(Element element)
Evicts the element from the store |
boolean |
evictFromOnDisk(int count,
long size)
Perform eviction to release on-disk resources |
boolean |
evictFromOnHeap(int count,
long size)
Perform eviction to release on-heap resources |
protected Element |
expireElement(Object key)
Evicts the element for the given key, if it exists and is expired |
void |
expireElements()
Expire all elements. |
void |
fill(Element element)
Add this element to the cache if the key is already present or the add can succeed without resorting to eviction. |
void |
flush()
Flush to disk only if the cache is diskPersistent. |
Element |
get(Object key)
Gets an item from the cache. |
long |
getApproximateDiskByteSize()
Return the approximate disk size in bytes |
long |
getApproximateDiskCountSize()
Return the approximate disk size |
float |
getApproximateDiskHitRate()
Return the approximate disk hit rate |
float |
getApproximateDiskMissRate()
Return the approximate disk miss rate |
long |
getApproximateHeapByteSize()
Return the approximate heap size in bytes |
long |
getApproximateHeapCountSize()
Return the approximate heap size |
float |
getApproximateHeapHitRate()
Return the approximate heap hit rate |
float |
getApproximateHeapMissRate()
Return the approximate heap miss rate |
protected static int |
getInitialCapacityForLoadFactor(int maximumSizeGoal,
float loadFactor)
Calculates the initialCapacity for a desired maximumSize goal and loadFactor. |
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. |
Set |
getPresentPinnedKeys()
Returns all the keys that are pinned, for which there is a mapping present |
Element |
getQuiet(Object key)
Gets an item from the cache, without updating statistics. |
int |
getSize()
Returns the current store size. |
Status |
getStatus()
Gets the status of the MemoryStore. |
int |
getTerracottaClusteredSize()
Returns nothing since a disk store isn't clustered |
boolean |
hasAbortedSizeOf()
Checks if the cache may contain elements for which the SizeOf engine gave up and only partially calculated the size. |
boolean |
isFull()
An algorithm to tell if the MemoryStore is at or beyond its carrying capacity. |
boolean |
isPersistent()
Is this store persistent (data survives a JVM restart) |
boolean |
isPinned(Object key)
Check if the key is pinned |
boolean |
isTierPinned()
Is this TierableStore pinned ? |
protected Set<?> |
keySet()
Returns the keySet for this store |
void |
loggingChanged(boolean oldValue,
boolean newValue)
Indicates a change in the configuration for enable/disable logging |
void |
maxBytesLocalDiskChanged(long oldValue,
long newValue)
Indicates a change in the configuration for maxBytesLocalDisk setting |
void |
maxBytesLocalHeapChanged(long oldValue,
long newValue)
Indicates a change in the configuration for maxBytesLocalHeap setting |
void |
memoryCapacityChanged(int oldCapacity,
int newCapacity)
Indicates a change in the configurations memory store capacity |
protected void |
notifyDirectEviction(Element element)
Called when an element is evicted even before it could be installed inside the store |
boolean |
put(Element element)
Puts an item in the store. |
Element |
putIfAbsent(Element element)
Put an element in the store if no element is currently mapped to the elements key. |
boolean |
putWithWriter(Element element,
CacheWriterManager writerManager)
Puts an item into the store and the cache writer manager in an atomic operation |
void |
recalculateSize(Object key)
Recalculate size of the element mapped to the key |
void |
registered(CacheConfiguration config)
Indicates that this listener was registered with the given configuration |
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)
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. |
boolean |
removeIfNotPinned(Object key)
This method will only remove if the element or the store is not pinned and the key is present in the store |
void |
removeNoReturn(Object key)
Removes an item from the cache. |
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)
Replace the cached element only if an Element is currently cached for this key |
boolean |
replace(Element old,
Element element,
ElementValueComparator comparator)
Replace the cached element only if the value of the current Element is equal to the value of the supplied old Element. |
void |
setInMemoryEvictionPolicy(Policy policy)
Sets the eviction policy strategy. |
void |
setPinned(Object key,
boolean pinned)
Mark the key as pinned or not |
void |
timeToIdleChanged(long oldTti,
long newTti)
Indicates a change in the configurations time to idle |
void |
timeToLiveChanged(long oldTtl,
long newTtl)
Indicates a change in the configurations time to live |
void |
unpinAll()
unpin all pinned keys |
| Methods inherited from class net.sf.ehcache.store.AbstractStore |
|---|
addStoreListener, executeQuery, getAll, getAllQuiet, getEventListenerList, getSearchAttribute, isCacheCoherent, isClusterCoherent, isNodeCoherent, putAll, removeAll, removeStoreListener, setAttributeExtractors, setNodeCoherent, waitUntilClusterCoherent |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface net.sf.ehcache.store.Store |
|---|
addStoreListener, executeQuery, getAll, getAllQuiet, getSearchAttribute, isCacheCoherent, isClusterCoherent, isNodeCoherent, putAll, removeAll, removeStoreListener, setAttributeExtractors, setNodeCoherent, waitUntilClusterCoherent |
| Constructor Detail |
|---|
protected MemoryStore(Ehcache cache,
Pool pool,
boolean notify,
MemoryStore.BackingFactory factory)
cache - the cachepool - the pool tracking the on-heap usagenotify - whether to notify the Cache's EventNotificationService on eviction and expiry| Method Detail |
|---|
protected static int getInitialCapacityForLoadFactor(int maximumSizeGoal,
float loadFactor)
maximumSizeGoal - the desired maximum size goalloadFactor - the load factor
public static MemoryStore create(Ehcache cache,
Pool pool)
cache - the cachepool - the pool tracking the on-heap usage
public void unpinAll()
unpinAll in interface Store
public void setPinned(Object key,
boolean pinned)
setPinned in interface Storekey - the key to be pinned or notpinned - true if the key should be pinned, false otherwisepublic boolean isPinned(Object key)
isPinned in interface Storekey - the key to be checked
true if the element is pinnedpublic void fill(Element element)
fill in interface TierableStoreelement - element to be addedpublic boolean removeIfNotPinned(Object key)
removeIfNotPinned in interface TierableStorekey - the key to the element
Store.remove(Object)
public boolean put(Element element)
throws CacheException
put in interface Storeelement - the element to add
CacheException
public boolean putWithWriter(Element element,
CacheWriterManager writerManager)
throws CacheException
putWithWriter in interface StoreCacheExceptionpublic final Element get(Object key)
Element is updated.
get in interface Storekey - the key of the Element
public final Element getQuiet(Object key)
getQuiet in interface Storekey - the cache key
public Element remove(Object key)
remove in interface Storekey - the key of the Element, usually a String
public void removeNoReturn(Object key)
removeNoReturn in interface TierableStorepublic boolean isTierPinned()
isTierPinned in interface TierableStorepublic Set getPresentPinnedKeys()
getPresentPinnedKeys in interface TierableStorepublic boolean isPersistent()
isPersistent in interface TierableStore
public final Element removeWithWriter(Object key,
CacheWriterManager writerManager)
throws CacheException
removeWithWriter in interface StoreCacheExceptionpublic final boolean bufferFull()
bufferFull in interface Storepublic void expireElements()
expireElements in interface Storeprotected Element expireElement(Object key)
key - the key
public final void removeAll()
throws CacheException
removeAll in interface StoreCacheExceptionpublic void dispose()
dispose in interface Storepublic void flush()
flush in interface Storepublic final List<?> getKeys()
getKeys in interface Storeprotected Set<?> keySet()
public final int getSize()
getSize in interface Storepublic final int getTerracottaClusteredSize()
getTerracottaClusteredSize in interface Storepublic final boolean containsKey(Object key)
containsKey in interface Storekey - The Element key
protected void notifyDirectEviction(Element element)
element - the evicted elementpublic final boolean isFull()
public final boolean canPutWithoutEvicting(Element element)
element - the element
public Object getInternalContext()
getInternalContext in interface Storepublic final Status getStatus()
getStatus in interface Store
public void timeToIdleChanged(long oldTti,
long newTti)
timeToIdleChanged in interface CacheConfigurationListeneroldTti - previous time to idle valuenewTti - new time to idle value
public void timeToLiveChanged(long oldTtl,
long newTtl)
timeToLiveChanged in interface CacheConfigurationListeneroldTtl - previous time to live valuenewTtl - new time to live value
public void diskCapacityChanged(int oldCapacity,
int newCapacity)
diskCapacityChanged in interface CacheConfigurationListeneroldCapacity - previous capacitynewCapacity - new capacity
public void loggingChanged(boolean oldValue,
boolean newValue)
loggingChanged in interface CacheConfigurationListeneroldValue - old value whether logging was enabled or notnewValue - new value whether logging was enabled or not
public void memoryCapacityChanged(int oldCapacity,
int newCapacity)
memoryCapacityChanged in interface CacheConfigurationListeneroldCapacity - previous capacitynewCapacity - new capacitypublic void registered(CacheConfiguration config)
registered in interface CacheConfigurationListenerpublic void deregistered(CacheConfiguration config)
deregistered in interface CacheConfigurationListener
public void maxBytesLocalHeapChanged(long oldValue,
long newValue)
maxBytesLocalHeapChanged in interface CacheConfigurationListeneroldValue - old value in bytesnewValue - new value in bytes
public void maxBytesLocalDiskChanged(long oldValue,
long newValue)
maxBytesLocalDiskChanged in interface CacheConfigurationListeneroldValue - old value in bytesnewValue - new value in bytespublic boolean containsKeyInMemory(Object key)
containsKeyInMemory in interface Storekey - The Element key
public boolean containsKeyOffHeap(Object key)
containsKeyOffHeap in interface Storekey - The Element key
public boolean containsKeyOnDisk(Object key)
containsKeyOnDisk in interface Storekey - The Element key
public Policy getInMemoryEvictionPolicy()
getInMemoryEvictionPolicy in interface StoreStore.setInMemoryEvictionPolicy(Policy)public int getInMemorySize()
getInMemorySize in interface Storepublic long getInMemorySizeInBytes()
getInMemorySizeInBytes in interface Storepublic int getOffHeapSize()
getOffHeapSize in interface Storepublic long getOffHeapSizeInBytes()
getOffHeapSizeInBytes in interface Storepublic int getOnDiskSize()
getOnDiskSize in interface Storepublic long getOnDiskSizeInBytes()
getOnDiskSizeInBytes in interface Storepublic boolean hasAbortedSizeOf()
hasAbortedSizeOf in interface StorehasAbortedSizeOf in class AbstractStorepublic void setInMemoryEvictionPolicy(Policy policy)
setInMemoryEvictionPolicy in interface Storepolicy - the new policy
public Element putIfAbsent(Element element)
throws NullPointerException
putIfAbsent in interface Storeelement - element to be added
NullPointerException - if the element is null, or has a null keyprotected boolean evict(Element element)
element - the element to be evicted
public Element removeElement(Element element,
ElementValueComparator comparator)
throws NullPointerException
removeElement in interface Storeelement - Element to be removedcomparator - ElementValueComparator to use to compare elements
NullPointerException - if the element is null, or has a null key
public boolean replace(Element old,
Element element,
ElementValueComparator comparator)
throws NullPointerException,
IllegalArgumentException
replace in interface Storeold - 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 equal
public Element replace(Element element)
throws NullPointerException
replace in interface Storeelement - Element to be cached
NullPointerException - if the Element is null or has a null keypublic Object getMBean()
getMBean in interface Store
public boolean evictFromOnHeap(int count,
long size)
evictFromOnHeap in interface PoolableStorecount - the number of elements to evictsize - the size in bytes to free (hint)
public boolean evictFromOnDisk(int count,
long size)
evictFromOnDisk in interface PoolableStorecount - the number of elements to evictsize - the size in bytes to free (hint)
public float getApproximateDiskHitRate()
getApproximateDiskHitRate in interface PoolableStorepublic float getApproximateDiskMissRate()
getApproximateDiskMissRate in interface PoolableStorepublic long getApproximateDiskCountSize()
getApproximateDiskCountSize in interface PoolableStorepublic long getApproximateDiskByteSize()
getApproximateDiskByteSize in interface PoolableStorepublic float getApproximateHeapHitRate()
getApproximateHeapHitRate in interface PoolableStorepublic float getApproximateHeapMissRate()
getApproximateHeapMissRate in interface PoolableStorepublic long getApproximateHeapCountSize()
getApproximateHeapCountSize in interface PoolableStorepublic long getApproximateHeapByteSize()
getApproximateHeapByteSize in interface PoolableStorepublic Collection<Element> elementSet()
public void recalculateSize(Object key)
AbstractStore
recalculateSize in interface StorerecalculateSize in class AbstractStorekey - the key
|
ehcache | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||