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

public final Class CopyingCacheStore<T extends net.sf.ehcache.store.Store>

extends AbstractCopyingCacheStore<T extends Store>
Class Inheritance
Type Parameters
<T>
the store type it wraps
Imports
net.sf.ehcache.Element, net.sf.ehcache.config.CacheConfiguration, net.sf.ehcache.store.compound.ReadWriteCopyStrategy

Copies elements, either on read, write or both before using the underlying store to actually store things When copying both ways, the store might not see the same types being stored
Author
Alex Snaps

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Constructor Summary

AccessConstructor and Description
public
CopyingCacheStore(T
the real store
store
,
boolean
whether to copy on reads
copyOnRead
,
boolean
whether to copy on writes
copyOnWrite
,
ReadWriteCopyStrategy<Element>
the copy strategy to use on every copy operation
copyStrategyInstance
,
ClassLoader
classloader of the containing cache
loader
)

Creates a copying instance of store, that wraps the actual storage

Method Summary

Modifier and TypeMethod and Description
private static boolean
pack-priv static boolean

Returns:

true is copying is required, otherwise false
requiresCopy
(final CacheConfiguration
the cache config
cacheConfiguration
)

Checks whether configuration enables copying

private static <
the Store type
T extends Store
>
CopyingCacheStore<T>

Returns:

the wrapped store
wrap
(final T
the store to wrap
cacheStore
,
final CacheConfiguration
the cache config backed by this store
cacheConfiguration
)

Wraps (always) with the proper configured CopyingCacheStore

public static Store

Returns:

the wrapped Store if copying is required, or the Store instance passed in
wrapIfCopy
(final Store
the store
cacheStore
,
final CacheConfiguration
the cache config for that store
cacheConfiguration
)

Wraps the Store instance passed in, should any copy occur

public static ElementValueComparator

Returns:

the comparator passed if no copy needed, a wrapped comparator otherwise
wrapIfCopy
(final ElementValueComparator
the comparator to wrap
comparator
,
final CacheConfiguration
the cache configuration
cacheConfiguration
)

Wraps the given net.sf.ehcache.store.ElementValueComparator if the configuration requires copy on read

Inherited from net.sf.ehcache.store.AbstractCopyingCacheStore:
addStoreListenerbufferFullcontainsKeycontainsKeyInMemorycontainsKeyOffHeapcontainsKeyOnDiskdisposeexecuteQueryexpireElementsflushgetgetAllgetAllQuietgetCopyStrategyHandlergetInMemoryEvictionPolicygetInMemorySizegetInMemorySizeInBytesgetInternalContextgetKeysgetMBeangetOffHeapSizegetOffHeapSizeInBytesgetOnDiskSizegetOnDiskSizeInBytesgetQuietgetSearchAttributegetSearchAttributesgetSizegetStatusgetTerracottaClusteredSizegetUnderlyingStorehasAbortedSizeOfisCacheCoherentisClusterCoherentisNodeCoherentputputAllputIfAbsentputWithWriterrecalculateSizeremoveremoveAllremoveAllremoveElementremoveStoreListenerremoveWithWriterreplacereplacesetAttributeExtractorssetInMemoryEvictionPolicysetNodeCoherentwaitUntilClusterCoherent

Constructor Detail

CopyingCacheStoreback to summary
public CopyingCacheStore(T store, boolean copyOnRead, boolean copyOnWrite, ReadWriteCopyStrategy<Element> copyStrategyInstance, ClassLoader loader)

Creates a copying instance of store, that wraps the actual storage

Parameters
store:T

the real store

copyOnRead:boolean

whether to copy on reads

copyOnWrite:boolean

whether to copy on writes

copyStrategyInstance:ReadWriteCopyStrategy<Element>

the copy strategy to use on every copy operation

loader:ClassLoader

classloader of the containing cache

Method Detail

isCopyOnReadAndCopyOnWriteback to summary
private static boolean isCopyOnReadAndCopyOnWrite(final CacheConfiguration cacheConfiguration)
requiresCopyback to summary
pack-priv static boolean requiresCopy(final CacheConfiguration cacheConfiguration)

Checks whether configuration enables copying

Parameters
cacheConfiguration:CacheConfiguration

the cache config

Returns:boolean

true is copying is required, otherwise false

wrapback to summary
private static <T extends Store> CopyingCacheStore<T> wrap(final T cacheStore, final CacheConfiguration cacheConfiguration)

Wraps (always) with the proper configured CopyingCacheStore

Parameters
<T>
the Store type
cacheStore:T

the store to wrap

cacheConfiguration:CacheConfiguration

the cache config backed by this store

Returns:CopyingCacheStore<T>

the wrapped store

wrapIfCopyback to summary
public static Store wrapIfCopy(final Store cacheStore, final CacheConfiguration cacheConfiguration)

Wraps the Store instance passed in, should any copy occur

Parameters
cacheStore:Store

the store

cacheConfiguration:CacheConfiguration

the cache config for that store

Returns:Store

the wrapped Store if copying is required, or the Store instance passed in

wrapIfCopyback to summary
public static ElementValueComparator wrapIfCopy(final ElementValueComparator comparator, final CacheConfiguration cacheConfiguration)

Wraps the given net.sf.ehcache.store.ElementValueComparator if the configuration requires copy on read

Parameters
comparator:ElementValueComparator

the comparator to wrap

cacheConfiguration:CacheConfiguration

the cache configuration

Returns:ElementValueComparator

the comparator passed if no copy needed, a wrapped comparator otherwise

net.sf.ehcache.store back to summary

private Class CopyingCacheStore.CopyingElementValueComparator

extends Object
implements ElementValueComparator
Class Inheritance
  • java.lang.Object
  • net.sf.ehcache.store.CopyingCacheStore.CopyingElementValueComparator
All Implemented Interfaces
net.sf.ehcache.store.ElementValueComparator

An net.sf.ehcache.store.ElementValueComparator which handles copy on read

Field Summary

Modifier and TypeField and Description
private final CopyStrategyHandler
private final ElementValueComparator

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Element
element to compare
e1
,
Element
element to compare
e2
)

Implements net.sf.ehcache.store.ElementValueComparator.equals.

Compare the two elements.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

copyStrategyHandlerback to summary
private final CopyStrategyHandler copyStrategyHandler
delegateback to summary
private final ElementValueComparator delegate

Constructor Detail

CopyingElementValueComparatorback to summary
public CopyingElementValueComparator(ElementValueComparator delegate, CopyStrategyHandler copyStrategyHandler)

Method Detail

equalsback to summary
public boolean equals(Element e1, Element e2)

Implements net.sf.ehcache.store.ElementValueComparator.equals.

Doc from net.sf.ehcache.store.ElementValueComparator.equals.

Compare the two elements. Null values have to be supported.

Parameters
e1:Element

element to compare

e2:Element

element to compare

Returns:boolean

true if the elements are equal

Annotations
@Override