|
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.compound.CompoundStore
public abstract class CompoundStore
The store used by default in Ehcache version 2. It is compound in the sense that whether the element is in memory or on disk, the key is held in memory. This store does not suffer from races which could occur in the older MemoryStore and DiskStore which could theoretically cause a cache miss if an element was moving between the stores due to overflow or retrieval. Subclasses allow for memory only, overflow to disk and persist to disk.
Field Summary |
---|
Fields inherited from interface net.sf.ehcache.store.Store |
---|
CLUSTER_COHERENT, NODE_COHERENT |
Constructor Summary | |
---|---|
CompoundStore(net.sf.ehcache.store.compound.InternalElementSubstituteFactory<?> primary,
boolean copyOnRead,
boolean copyOnWrite,
ReadWriteCopyStrategy<Element> copyStrategy)
Create a CompoundStore using the supplied factory as the primary factory. |
|
CompoundStore(net.sf.ehcache.store.compound.InternalElementSubstituteFactory<?> primary,
IdentityElementSubstituteFactory identity)
Create a CompoundStore using the supplied primary, and designated identity factory. |
|
CompoundStore(net.sf.ehcache.store.compound.InternalElementSubstituteFactory<?> primary,
IdentityElementSubstituteFactory identity,
boolean copyOnRead,
boolean copyOnWrite,
ReadWriteCopyStrategy<Element> copyStrategy)
Create a CompoundStore using the supplied primary, and designated identity factory. |
Method Summary | ||
---|---|---|
boolean |
containsKey(Object key)
A check to see if a key is in the Store. |
|
void |
dispose()
Prepares for shutdown. |
|
Set<Element> |
elementSet()
Get a set view of the elements in this store |
|
boolean |
evict(Object key,
Object substitute)
Remove the matching mapping. |
|
boolean |
fault(Object key,
Object expect,
Object fault)
Atomically switch (CAS) the expect representation of this element for the
fault representation. |
|
Element |
get(Object key)
Gets an item from the cache. |
|
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 disk store. |
|
Element |
getQuiet(Object key)
Gets an Element from the Store, without updating statistics |
|
|
getRandomSample(ElementSubstituteFilter<T> factory,
int sampleSize,
Object keyHint)
Select a random sample of elements generated by the supplied factory. |
|
int |
getSize()
Returns the current local store size |
|
Status |
getStatus()
Returns the cache status. |
|
Set<Object> |
keySet()
Get a set view of the keys in this store |
|
boolean |
put(Element element)
Puts an item into the store. |
|
Element |
putIfAbsent(Element element)
Put an element in the store if no element is currently mapped to the elements key. |
|
boolean |
putRawIfAbsent(Object key,
Object encoded)
Put the given encoded element directly into the store |
|
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 item from the cache. |
|
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. |
|
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. |
|
boolean |
tryFault(Object key,
Object expect,
Object fault)
Try to atomically switch (CAS) the expect representation of this element for the
fault representation. |
|
Object |
unretrievedGet(Object key)
Return the unretrieved (undecoded) value for this key |
Methods inherited from class net.sf.ehcache.store.AbstractStore |
---|
addStoreListener, executeQuery, getEventListenerList, getSearchAttribute, isCacheCoherent, isClusterCoherent, isNodeCoherent, 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 |
---|
bufferFull, containsKeyInMemory, containsKeyOffHeap, containsKeyOnDisk, expireElements, flush, getInMemoryEvictionPolicy, getInMemorySize, getInMemorySizeInBytes, getMBean, getOffHeapSize, getOffHeapSizeInBytes, getOnDiskSize, getOnDiskSizeInBytes, getTerracottaClusteredSize, setInMemoryEvictionPolicy |
Constructor Detail |
---|
public CompoundStore(net.sf.ehcache.store.compound.InternalElementSubstituteFactory<?> primary, boolean copyOnRead, boolean copyOnWrite, ReadWriteCopyStrategy<Element> copyStrategy)
primary
- factory which new elements are passed throughcopyOnRead
- true should we copy Elements on reads, otherwise falsecopyOnWrite
- true should we copy Elements on writes, otherwise falsecopyStrategy
- the strategy to copy elements (needs to be non null if copyOnRead or copyOnWrite is true)public CompoundStore(net.sf.ehcache.store.compound.InternalElementSubstituteFactory<?> primary, IdentityElementSubstituteFactory identity)
primary
- factory which new elements are passed throughidentity
- factory which performs identity substitutionpublic CompoundStore(net.sf.ehcache.store.compound.InternalElementSubstituteFactory<?> primary, IdentityElementSubstituteFactory identity, boolean copyOnRead, boolean copyOnWrite, ReadWriteCopyStrategy<Element> copyStrategy)
primary
- factory which new elements are passed throughidentity
- factory which performs identity substitutioncopyOnRead
- true should we copy Elements on reads, otherwise falsecopyOnWrite
- true should we copy Elements on writes, otherwise falsecopyStrategy
- the strategy to copy elements (needs to be non null if copyOnRead or copyOnWrite is true)Method Detail |
---|
public boolean put(Element element)
public boolean putWithWriter(Element element, CacheWriterManager writerManager)
public Element get(Object key)
public Element getQuiet(Object key)
Element
from the Store, without updating statistics
public Object unretrievedGet(Object key)
key
- key to lookup
public boolean putRawIfAbsent(Object key, Object encoded)
public List getKeys()
Serializable
keyspublic Set<Object> keySet()
public Set<Element> elementSet()
public Element remove(Object key)
public Element removeWithWriter(Object key, CacheWriterManager writerManager)
public void removeAll()
CacheEventListener
s they are notified of the expiry or removal
of the Element
as each is removed.
public void dispose()
public int getSize()
public Status getStatus()
public boolean containsKey(Object key)
key
- The Element key
public Object getInternalContext()
public 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 keypublic boolean fault(Object key, Object expect, Object fault)
expect
representation of this element for the
fault
representation.
A successful switch will return true
, and free the replaced element/element-proxy.
A failed switch will return false
and free the element/element-proxy which was not
installed.
key
- key to which this element (proxy) is mappedexpect
- element (proxy) expectedfault
- element (proxy) to install
true
if fault
was installedpublic boolean tryFault(Object key, Object expect, Object fault)
expect
representation of this element for the
fault
representation.
A successful switch will return true
, and free the replaced element/element-proxy.
A failed switch will return false
and free the element/element-proxy which was not
installed. Unlike fault
this method can return false
if the object
could not be installed due to lock contention.
key
- key to which this element (proxy) is mappedexpect
- element (proxy) expectedfault
- element (proxy) to install
true
if fault
was installedpublic boolean evict(Object key, Object substitute)
key
- key to match againstsubstitute
- optional value to match against
true
on a successful removepublic <T> List<T> getRandomSample(ElementSubstituteFilter<T> factory, int sampleSize, Object keyHint)
T
- type of the elements or element substitutesfactory
- generator of the given typesampleSize
- minimum number of elements to returnkeyHint
- a key on which we are currently working
|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |