Top Description Fields Constructors Methods
net.sf.ehcache.store

public Class LegacyStoreWrapper

extends AbstractStore
Class Inheritance
Imports
java.io.IOException, .Serializable, java.util.ArrayList, .HashSet, .List, net.sf.ehcache.CacheException, .Element, .Status, net.sf.ehcache.concurrent.LockType, .StripedReadWriteLockSync, .Sync, net.sf.ehcache.config.CacheConfiguration, net.sf.ehcache.event.RegisteredEventListeners, net.sf.ehcache.writer.CacheWriterManager, org.terracotta.context.annotations.ContextChild

A wrapper to convert a legacy pair of stores into a new style compound store.
Author
Chris Dennis

Field Summary

Modifier and TypeField and Description
private final CacheConfiguration
private final Store
private final RegisteredEventListeners
private final Store
private final StripedReadWriteLockSync
private static final int
Inherited from net.sf.ehcache.store.AbstractStore:
attributeExtractorssearchManager

Constructor Summary

AccessConstructor and Description
public
LegacyStoreWrapper(Store
in-memory store
memory
,
Store
on disk store
disk
,
RegisteredEventListeners
event listener to fire on
eventListeners
,
CacheConfiguration
cache configuration
config
)

Create a correctly locked store wrapper around the supplied in-memory and on disk stores.

Method Summary

Modifier and TypeMethod and Description
public boolean
bufferFull()

Implements net.sf.ehcache.store.Store.bufferFull.

Some store types, such as the disk stores can fill their write buffers if puts come in too fast.
public boolean
containsKey(Object
The Element key
key
)

Implements net.sf.ehcache.store.Store.containsKey.

A check to see if a key is in the Store.
public boolean
containsKeyInMemory(Object
The Element key
key
)

Implements net.sf.ehcache.store.Store.containsKeyInMemory.

A check to see if a key is in the Store and is currently held in memory.
public boolean
containsKeyOffHeap(Object
The Element key
key
)

Implements net.sf.ehcache.store.Store.containsKeyOffHeap.

A check to see if a key is in the Store and is currently held off-heap.
public boolean
containsKeyOnDisk(Object
The Element key
key
)

Implements net.sf.ehcache.store.Store.containsKeyOnDisk.

A check to see if a key is in the Store and is currently held on disk.
public void
dispose()

Implements net.sf.ehcache.store.Store.dispose.

Prepares for shutdown.
public void
public void
flush()

Implements net.sf.ehcache.store.Store.flush.

Flush elements to persistent store.
public Element
get(Object key)

Implements net.sf.ehcache.store.Store.get.

Gets an item from the cache.
public Policy
public int
getInMemorySize()

Implements net.sf.ehcache.store.Store.getInMemorySize.

Returns the current local in-memory store size
public long
getInMemorySizeInBytes()

Implements net.sf.ehcache.store.Store.getInMemorySizeInBytes.

Gets the size of the in-memory portion of the store, in bytes.
public Object
getInternalContext()

Implements net.sf.ehcache.store.Store.getInternalContext.

This should not be used, and will generally return null
public List<E>
getKeys()

Implements net.sf.ehcache.store.Store.getKeys.

Gets an Array of the keys for all elements in the disk store.
public Object
getMBean()

Implements net.sf.ehcache.store.Store.getMBean.

Optional implementation specific MBean exposed by the store.
public Store
getMemoryStore()

Returns the underlying memory store for this legacy wrapper.

public int
getOffHeapSize()

Implements net.sf.ehcache.store.Store.getOffHeapSize.

Returns the current local off-heap store size
public long
getOffHeapSizeInBytes()

Implements net.sf.ehcache.store.Store.getOffHeapSizeInBytes.

Gets the size of the off-heap portion of the store, in bytes.
public int
getOnDiskSize()

Implements net.sf.ehcache.store.Store.getOnDiskSize.

Returns the current local on-disk store size
public long
getOnDiskSizeInBytes()

Implements net.sf.ehcache.store.Store.getOnDiskSizeInBytes.

Gets the size of the on-disk portion of the store, in bytes.
public Element
getQuiet(Object key)

Implements net.sf.ehcache.store.Store.getQuiet.

Gets an Element from the Store, without updating statistics
public int
getSize()

Implements net.sf.ehcache.store.Store.getSize.

Returns the current local store size

The size is the number of Elements in the memory store plus the number of Elements in the disk store.

public Status
getStatus()

Implements net.sf.ehcache.store.Store.getStatus.

Returns the cache status.
public int
getTerracottaClusteredSize()

Implements net.sf.ehcache.store.Store.getTerracottaClusteredSize.

Returns the current Terracotta clustered store size
public boolean
put(Element element)

Implements net.sf.ehcache.store.Store.put.

Puts an item into the store.
public Element
putIfAbsent(Element
element to be added
element
)

Implements net.sf.ehcache.store.Store.putIfAbsent.

Put an element in the store if no element is currently mapped to the elements key.
public boolean
putWithWriter(Element element, CacheWriterManager writerManager)

Implements net.sf.ehcache.store.Store.putWithWriter.

Puts an item into the store and the cache writer manager in an atomic operation
public Element
remove(Object key)

Implements net.sf.ehcache.store.Store.remove.

Removes an item from the cache.
public void
removeAll()

Implements net.sf.ehcache.store.Store.removeAll.

Remove all of the elements from the store.
public Element
removeElement(Element
Element to be removed
element
,
ElementValueComparator
ElementValueComparator to use to compare elements
comparator
)

Implements net.sf.ehcache.store.Store.removeElement.

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.
public Element
removeWithWriter(Object key, CacheWriterManager writerManager)

Implements net.sf.ehcache.store.Store.removeWithWriter.

Removes an item from the store and the cache writer manager in an atomic operation.
public boolean
replace(Element
Element to be test against
old
,
Element
Element to be cached
element
,
ElementValueComparator
ElementValueComparator to use to compare elements
comparator
)

Implements net.sf.ehcache.store.Store.replace.

Replace the cached element only if the value of the current Element is equal to the value of the supplied old Element.
public Element
replace(Element
Element to be cached
element
)

Implements net.sf.ehcache.store.Store.replace.

Replace the cached element only if an Element is currently cached for this key
public void
setInMemoryEvictionPolicy(Policy
the new policy
policy
)

Implements net.sf.ehcache.store.Store.setInMemoryEvictionPolicy.

Sets the eviction policy strategy.
Inherited from net.sf.ehcache.store.AbstractStore:
addStoreListenerexecuteQuerygetAllgetAllQuietgetEventListenerListgetSearchAttributegetSearchAttributeshasAbortedSizeOfisCacheCoherentisClusterCoherentisNodeCoherentputAllrecalculateSizeremoveAllremoveStoreListenersetAttributeExtractorssetNodeCoherentwaitUntilClusterCoherent

Field Detail

configback to summary
private final CacheConfiguration config
diskback to summary
private final Store disk
Annotations
@ContextChild
eventListenersback to summary
private final RegisteredEventListeners eventListeners
memoryback to summary
private final Store memory
Annotations
@ContextChild
syncback to summary
private final StripedReadWriteLockSync sync
SYNC_STRIPESback to summary
private static final int SYNC_STRIPES

Constructor Detail

LegacyStoreWrapperback to summary
public LegacyStoreWrapper(Store memory, Store disk, RegisteredEventListeners eventListeners, CacheConfiguration config)

Create a correctly locked store wrapper around the supplied in-memory and on disk stores.

Parameters
memory:Store

in-memory store

disk:Store

on disk store

eventListeners:RegisteredEventListeners

event listener to fire on

config:CacheConfiguration

cache configuration

Method Detail

bufferFullback to summary
public boolean bufferFull()

Implements net.sf.ehcache.store.Store.bufferFull.

Doc from net.sf.ehcache.store.Store.bufferFull.

Some store types, such as the disk stores can fill their write buffers if puts come in too fast. The thread will wait for a short time before checking again.

Returns:boolean

true if the store write buffer is backed up.

containsKeyback to summary
public boolean containsKey(Object key)

Implements net.sf.ehcache.store.Store.containsKey.

Doc from net.sf.ehcache.store.Store.containsKey.

A check to see if a key is in the Store.

Parameters
key:Object

The Element key

Returns:boolean

true if found. No check is made to see if the Element is expired. 1.2

containsKeyInMemoryback to summary
public boolean containsKeyInMemory(Object key)

Implements net.sf.ehcache.store.Store.containsKeyInMemory.

Doc from net.sf.ehcache.store.Store.containsKeyInMemory.

A check to see if a key is in the Store and is currently held in memory.

Parameters
key:Object

The Element key

Returns:boolean

true if found. No check is made to see if the Element is expired.

containsKeyOffHeapback to summary
public boolean containsKeyOffHeap(Object key)

Implements net.sf.ehcache.store.Store.containsKeyOffHeap.

Doc from net.sf.ehcache.store.Store.containsKeyOffHeap.

A check to see if a key is in the Store and is currently held off-heap.

Parameters
key:Object

The Element key

Returns:boolean

true if found. No check is made to see if the Element is expired.

containsKeyOnDiskback to summary
public boolean containsKeyOnDisk(Object key)

Implements net.sf.ehcache.store.Store.containsKeyOnDisk.

Doc from net.sf.ehcache.store.Store.containsKeyOnDisk.

A check to see if a key is in the Store and is currently held on disk.

Parameters
key:Object

The Element key

Returns:boolean

true if found. No check is made to see if the Element is expired.

disposeback to summary
public void dispose()

Implements net.sf.ehcache.store.Store.dispose.

Doc from net.sf.ehcache.store.Store.dispose.

Prepares for shutdown.

expireElementsback to summary
public void expireElements()

Implements net.sf.ehcache.store.Store.expireElements.

Doc from net.sf.ehcache.store.Store.expireElements.

Expire all elements.

flushback to summary
public void flush() throws IOException

Implements net.sf.ehcache.store.Store.flush.

Doc from net.sf.ehcache.store.Store.flush.

Flush elements to persistent store.

Exceptions
IOException:
if any IO error occurs
getback to summary
public Element get(Object key)

Implements net.sf.ehcache.store.Store.get.

Doc from net.sf.ehcache.store.Store.get.

Gets an item from the cache.

getInMemoryEvictionPolicyback to summary
public Policy getInMemoryEvictionPolicy()

Implements net.sf.ehcache.store.Store.getInMemoryEvictionPolicy.

Returns:Policy

Doc from net.sf.ehcache.store.Store.getInMemoryEvictionPolicy.

the current eviction policy. This may not be the configured policy, if it has been dynamically set.

getInMemorySizeback to summary
public int getInMemorySize()

Implements net.sf.ehcache.store.Store.getInMemorySize.

Doc from net.sf.ehcache.store.Store.getInMemorySize.

Returns the current local in-memory store size

Returns:int

the count of the Elements in the Store and in-memory on the local machine

getInMemorySizeInBytesback to summary
public long getInMemorySizeInBytes()

Implements net.sf.ehcache.store.Store.getInMemorySizeInBytes.

Doc from net.sf.ehcache.store.Store.getInMemorySizeInBytes.

Gets the size of the in-memory portion of the store, in bytes.

This method may be expensive to run, depending on implementation. Implementers may choose to return an approximate size.

Returns:long

the approximate in-memory size of the store in bytes

getInternalContextback to summary
public Object getInternalContext()

Implements net.sf.ehcache.store.Store.getInternalContext.

Doc from net.sf.ehcache.store.Store.getInternalContext.

This should not be used, and will generally return null

Returns:Object

some internal context (probably null)

getKeysback to summary
public List<E> getKeys()

Implements net.sf.ehcache.store.Store.getKeys.

Doc from net.sf.ehcache.store.Store.getKeys.

Gets an Array of the keys for all elements in the disk store.

Returns:List<E>

An List of java.io.Serializable keys

getMBeanback to summary
public Object getMBean()

Implements net.sf.ehcache.store.Store.getMBean.

Doc from net.sf.ehcache.store.Store.getMBean.

Optional implementation specific MBean exposed by the store.

Returns:Object

implementation specific management bean

getMemoryStoreback to summary
public Store getMemoryStore()

Returns the underlying memory store for this legacy wrapper.

getOffHeapSizeback to summary
public int getOffHeapSize()

Implements net.sf.ehcache.store.Store.getOffHeapSize.

Doc from net.sf.ehcache.store.Store.getOffHeapSize.

Returns the current local off-heap store size

Returns:int

the count of the Elements in the Store and off-heap on the local machine

getOffHeapSizeInBytesback to summary
public long getOffHeapSizeInBytes()

Implements net.sf.ehcache.store.Store.getOffHeapSizeInBytes.

Doc from net.sf.ehcache.store.Store.getOffHeapSizeInBytes.

Gets the size of the off-heap portion of the store, in bytes.

Returns:long

the approximate off-heap size of the store in bytes

getOnDiskSizeback to summary
public int getOnDiskSize()

Implements net.sf.ehcache.store.Store.getOnDiskSize.

Doc from net.sf.ehcache.store.Store.getOnDiskSize.

Returns the current local on-disk store size

Returns:int

the count of the Elements in the Store and on-disk on the local machine

getOnDiskSizeInBytesback to summary
public long getOnDiskSizeInBytes()

Implements net.sf.ehcache.store.Store.getOnDiskSizeInBytes.

Doc from net.sf.ehcache.store.Store.getOnDiskSizeInBytes.

Gets the size of the on-disk portion of the store, in bytes.

Returns:long

the on-disk size of the store in bytes

getQuietback to summary
public Element getQuiet(Object key)

Implements net.sf.ehcache.store.Store.getQuiet.

Doc from net.sf.ehcache.store.Store.getQuiet.

Gets an Element from the Store, without updating statistics

Returns:Element

The element

getSizeback to summary
public int getSize()

Implements net.sf.ehcache.store.Store.getSize.

Doc from net.sf.ehcache.store.Store.getSize.

Returns the current local store size

The size is the number of Elements in the memory store plus the number of Elements in the disk store.

Returns:int

the count of the Elements in the Store on the local machine

getStatusback to summary
public Status getStatus()

Implements net.sf.ehcache.store.Store.getStatus.

Doc from net.sf.ehcache.store.Store.getStatus.

Returns the cache status.

getTerracottaClusteredSizeback to summary
public int getTerracottaClusteredSize()

Implements net.sf.ehcache.store.Store.getTerracottaClusteredSize.

Doc from net.sf.ehcache.store.Store.getTerracottaClusteredSize.

Returns the current Terracotta clustered store size

Returns:int

the count of the Elements in the Store across the cluster

putback to summary
public boolean put(Element element) throws CacheException

Implements net.sf.ehcache.store.Store.put.

Doc from net.sf.ehcache.store.Store.put.

Puts an item into the store.

Returns:boolean

true if this is a new put for the key or element is null. Returns false if it was an update.

putIfAbsentback to summary
public Element putIfAbsent(Element element) throws NullPointerException

Implements net.sf.ehcache.store.Store.putIfAbsent.

Doc from net.sf.ehcache.store.Store.putIfAbsent.

Put an element in the store if no element is currently mapped to the elements key.

Parameters
element:Element

element to be added

Returns:Element

the element previously cached for this key, or null if none.

Exceptions
NullPointerException:
if the element is null, or has a null key
putWithWriterback to summary
public boolean putWithWriter(Element element, CacheWriterManager writerManager) throws CacheException

Implements net.sf.ehcache.store.Store.putWithWriter.

Doc from net.sf.ehcache.store.Store.putWithWriter.

Puts an item into the store and the cache writer manager in an atomic operation

Returns:boolean

true if this is a new put for the key or element is null. Returns false if it was an update.

removeback to summary
public Element remove(Object key)

Implements net.sf.ehcache.store.Store.remove.

Doc from net.sf.ehcache.store.Store.remove.

Removes an item from the cache.

removeAllback to summary
public void removeAll() throws CacheException

Implements net.sf.ehcache.store.Store.removeAll.

Doc from net.sf.ehcache.store.Store.removeAll.

Remove all of the elements from the store.

If there are registered CacheEventListeners they are notified of the expiry or removal of the Element as each is removed.

removeElementback to summary
public Element removeElement(Element element, ElementValueComparator comparator) throws NullPointerException

Implements net.sf.ehcache.store.Store.removeElement.

Doc from net.sf.ehcache.store.Store.removeElement.

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. This is a CAS operation. It is consistent even against a distributed cache that is not coherent. If the old value is stale when this operation is attempted the remove does not take place.

Parameters
element:Element

Element to be removed

comparator:ElementValueComparator

ElementValueComparator to use to compare elements

Returns:Element

the Element removed or null if no Element was removed

Exceptions
NullPointerException:
if the element is null, or has a null key
removeWithWriterback to summary
public Element removeWithWriter(Object key, CacheWriterManager writerManager) throws CacheException

Implements net.sf.ehcache.store.Store.removeWithWriter.

Doc from net.sf.ehcache.store.Store.removeWithWriter.

Removes an item from the store and the cache writer manager in an atomic operation.

replaceback to summary
public boolean replace(Element old, Element element, ElementValueComparator comparator) throws NullPointerException, IllegalArgumentException

Implements net.sf.ehcache.store.Store.replace.

Doc from net.sf.ehcache.store.Store.replace.

Replace the cached element only if the value of the current Element is equal to the value of the supplied old Element.

Parameters
old:Element

Element to be test against

element:Element

Element to be cached

comparator:ElementValueComparator

ElementValueComparator to use to compare elements

Returns:boolean

true is the Element was replaced

Exceptions
NullPointerException:
if the either Element is null or has a null key
IllegalArgumentException:
if the two Element keys are non-null but not equal
replaceback to summary
public Element replace(Element element) throws NullPointerException

Implements net.sf.ehcache.store.Store.replace.

Doc from net.sf.ehcache.store.Store.replace.

Replace the cached element only if an Element is currently cached for this key

Parameters
element:Element

Element to be cached

Returns:Element

the Element previously cached for this key, or null if no Element was cached

Exceptions
NullPointerException:
if the Element is null or has a null key
setInMemoryEvictionPolicyback to summary
public void setInMemoryEvictionPolicy(Policy policy)

Implements net.sf.ehcache.store.Store.setInMemoryEvictionPolicy.

Doc from net.sf.ehcache.store.Store.setInMemoryEvictionPolicy.

Sets the eviction policy strategy. The Store will use a policy at startup. The store may allow changing the eviction policy strategy dynamically. Otherwise implementations will throw an exception if this method is called.

Parameters
policy:Policy

the new policy