Top Description Inners Fields Constructors Methods
net.sf.ehcache.config

public Class CacheConfiguration

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Imports
net.sf.ehcache.Cache, .CacheException, .CacheManager, .EhcacheDefaultClassLoader, .Element, net.sf.ehcache.config.PersistenceConfiguration.Strategy, .PinningConfiguration.Store, .TerracottaConfiguration.Consistency, net.sf.ehcache.event.NotificationScope, net.sf.ehcache.search.attribute.DynamicAttributesExtractor, net.sf.ehcache.store.MemoryStoreEvictionPolicy, net.sf.ehcache.store.compound.ReadWriteCopyStrategy, org.slf4j.Logger, .LoggerFactory, java.util.ArrayList, .Collection, .Collections, .List, .Map, .Set, java.util.concurrent.CopyOnWriteArraySet

A value object used to represent cache configuration.

Construction Patterns

The recommended way of creating a Cache in Ehcache 2.0 and above is to create a CacheConfiguration object and pass it to the Cache constructor. See net.sf.ehcache.Cache#Cache(CacheConfiguration).

This class supports setter injection and also the fluent builder pattern. e.g. Cache cache = new Cache(new CacheConfiguration("test2", 1000).eternal(true).memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.FIFO));

Rather than proliferation of new constructors as new versions of Ehcache come out, it intended to add the new configuration to this class.

Another way to set configuration is declaratively in the ehcache.xml configuration file. e.g.

<cache name="testCache1"
  maxEntriesLocalHeap="10000"
  eternal="false"
  timeToIdleSeconds="3600"
  timeToLiveSeconds="10"
  overflowToDisk="true"
  diskPersistent="true"
  diskExpiryThreadIntervalSeconds="120"
  maxEntriesLocalDisk="10000"
/>

Dynamic Configuration

CacheConfiguration instances retrieved from Cache instances allow the dynamic modification of certain configuration properties. Currently the dynamic properties are: Dynamic changes are however not persistent across cache restarts. On restart the cache configuration will be reloaded from its original source, erasing any changes made previously at runtime.

Users should also take care of synchronizing threads externally, if a CacheConfiguration instance is going to be mutated by multiple threads concurrently. While CacheConfiguration instances will make changes properly visible to all threads, logic within individual methods (e.g. validation) isn't trying to provide any "thread safeness".

Authors
Greg Luck, Chris Dennis
Version
$Id: CacheConfiguration.java 10789 2018-04-26 02:08:13Z adahanne $

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
CacheConfiguration.BootstrapCacheLoaderFactoryConfiguration

Configuration for the BootstrapCacheLoaderFactoryConfiguration.

public static class
CacheConfiguration.CacheDecoratorFactoryConfiguration

Configuration for the CacheDecoratorFactoryConfiguration.

public static class
CacheConfiguration.CacheEventListenerFactoryConfiguration

Configuration for the CacheEventListenerFactory.

public static class
CacheConfiguration.CacheExceptionHandlerFactoryConfiguration

Configuration for the BootstrapCacheLoaderFactoryConfiguration.

public static class
CacheConfiguration.CacheExtensionFactoryConfiguration

Configuration for the CacheExtensionFactoryConfiguration.

public static class
CacheConfiguration.CacheLoaderFactoryConfiguration

Configuration for the CacheLoaderFactoryConfiguration.

private class
CacheConfiguration.DefaultCacheConfigurationListener

Default listener class which handles the size changes of the cache

private static enum
CacheConfiguration.PoolUsage

An enum to identify what pool a resource uses

public static enum
CacheConfiguration.TransactionalMode

Represents whether the Cache is transactional or not.

Field Summary

Modifier and TypeField and Description
protected CacheConfiguration.BootstrapCacheLoaderFactoryConfiguration
bootstrapCacheLoaderFactoryConfiguration

The BootstrapCacheLoaderFactoryConfiguration.

protected volatile List<CacheConfiguration.CacheDecoratorFactoryConfiguration>
cacheDecoratorConfigurations

The cache decorator factories added by BeanUtils.

protected volatile List<CacheConfiguration.CacheEventListenerFactoryConfiguration>
cacheEventListenerConfigurations

The event listener factories added by BeanUtils.

protected CacheConfiguration.CacheExceptionHandlerFactoryConfiguration
cacheExceptionHandlerFactoryConfiguration

The CacheExceptionHandlerFactoryConfiguration.

protected volatile List<CacheConfiguration.CacheExtensionFactoryConfiguration>
cacheExtensionConfigurations

The cache extension factories added by BeanUtils.

protected volatile List<CacheConfiguration.CacheLoaderFactoryConfiguration>
cacheLoaderConfigurations

The cache loader factories added by BeanUtils.

protected volatile long
cacheLoaderTimeoutMillis

Timeout in milliseconds for CacheLoader related calls

protected CacheWriterConfiguration
cacheWriterConfiguration

The CacheWriterConfiguration.

private volatile ClassLoader
protected volatile boolean
clearOnFlush

Sets whether the MemoryStore should be cleared when flush() is called on the cache - true by default.

private volatile boolean
private volatile Boolean
private volatile Boolean
private volatile CopyStrategyConfiguration
public static final CacheWriterConfiguration
DEFAULT_CACHE_WRITER_CONFIGURATION

The default cacheWriterConfiguration

public static final boolean
DEFAULT_CLEAR_ON_FLUSH

Default value for clearOnFlush

public static final boolean
DEFAULT_COPY_ON_READ

Default value for copyOnRead

public static final boolean
DEFAULT_COPY_ON_WRITE

Default value for copyOnRead

public static final CopyStrategyConfiguration
DEFAULT_COPY_STRATEGY_CONFIGURATION

Default copyStrategyConfiguration

public static final int
DEFAULT_DISK_ACCESS_STRIPES

Default number of diskAccessStripes.

public static final boolean
DEFAULT_DISK_PERSISTENT

Default value for diskPersistent

public static final boolean
DEFAULT_ETERNAL_VALUE

Default eternal value

public static final long
DEFAULT_EXPIRY_THREAD_INTERVAL_SECONDS

The default interval between runs of the expiry thread.

public static final boolean
DEFAULT_LOGGING

Logging is off by default.

public static final long
DEFAULT_MAX_BYTES_OFF_HEAP

Default maxBytesOffHeap value

public static final long
DEFAULT_MAX_BYTES_ON_DISK

Default maxBytesOnDisk value

public static final long
DEFAULT_MAX_BYTES_ON_HEAP

Default maxBytesOnHeap value

public static final int
DEFAULT_MAX_ELEMENTS_ON_DISK

Default value for maxElementsOnDisk

public static final long
DEFAULT_MAX_ENTRIES_IN_CACHE

Default value for maxEntriesInCache

public static final MemoryStoreEvictionPolicy
DEFAULT_MEMORY_STORE_EVICTION_POLICY

The default memory store eviction policy is LRU.

public static final int
DEFAULT_SPOOL_BUFFER_SIZE

Set a buffer size for the spool of approx 30MB.

public static final boolean
DEFAULT_STATISTICS

Default value for statistics

public static final CacheConfiguration.TransactionalMode
DEFAULT_TRANSACTIONAL_MODE

Default value for transactionalMode

public static final long
DEFAULT_TTI

Default value for tti

public static final long
DEFAULT_TTL

Default value for ttl

protected volatile int
diskAccessStripes

The number of concurrent disk access stripes.

protected volatile long
diskExpiryThreadIntervalSeconds

The interval in seconds between runs of the disk expiry thread.

protected volatile Boolean
diskPersistent

For caches that overflow to disk, whether the disk cache persists between CacheManager instances.

protected volatile int
diskSpoolBufferSizeMB

The size of the disk spool used to buffer writes

private volatile Set<DynamicSearchListener>
private volatile ElementValueComparatorConfiguration
protected volatile boolean
eternal

Sets whether elements are eternal.

private DynamicAttributesExtractor
private volatile boolean
private static final int
protected volatile Set<CacheConfigurationListener>
listeners

The listeners for this configuration.

private static final Logger
protected volatile boolean
logging

Indicates whether logging is enabled or not.

private Long
private volatile boolean
private String
private Integer
private Long
private String
private Integer
private Long
private volatile boolean
private String
private Integer
protected volatile int
maxElementsOnDisk

the maximum objects to be held in the net.sf.ehcache.store.disk.DiskStore.

protected volatile long
maxEntriesInCache

the maximum entries to be held in the cache

private volatile boolean
protected volatile Integer
maxEntriesLocalHeap

the maximum objects to be held in the net.sf.ehcache.store.MemoryStore.

protected volatile MemoryStoreEvictionPolicy
memoryStoreEvictionPolicy

The policy used to evict elements from the net.sf.ehcache.store.MemoryStore.

protected volatile String
name

the name of the cache.

private CacheConfiguration.PoolUsage
private CacheConfiguration.PoolUsage
private CacheConfiguration.PoolUsage
protected volatile Boolean
overflowToDisk

whether elements can overflow to disk when the in-memory cache has reached the set limit.

protected volatile Boolean
overflowToOffHeap

whether elements can overflow to off heap memory when the in-memory cache has reached the set limit.

private volatile PersistenceConfiguration
protected volatile PinningConfiguration
pinningConfiguration

The PinningConfiguration.

private volatile Searchable
private volatile SizeOfPolicyConfiguration
private volatile boolean
protected TerracottaConfiguration
terracottaConfiguration

The TerracottaConfiguration.

protected volatile long
timeToIdleSeconds

the time to idle for an element before it expires.

protected volatile long
timeToLiveSeconds

Sets the time to idle for an element before it expires.

private volatile CacheConfiguration.TransactionalMode

Constructor Summary

AccessConstructor and Description
public
CacheConfiguration()

Default constructor.

public
CacheConfiguration(String
the name of the cache. Note that "default" is a reserved name for the defaultCache.
name
,
int
the maximum number of elements in memory, before they are evicted (0 == no limit)
maxEntriesLocalHeap
)

Create a new cache configuration.

Method Summary

Modifier and TypeMethod and Description
public final void
addBootstrapCacheLoaderFactory(CacheConfiguration.BootstrapCacheLoaderFactoryConfiguration factory)

Allows BeanHandler to add the CacheManagerEventListener to the configuration.

public final void
addCacheDecoratorFactory(CacheConfiguration.CacheDecoratorFactoryConfiguration factory)

Used by BeanUtils to add each cacheDecoratorFactory to the cache configuration.

public final void
addCacheEventListenerFactory(CacheConfiguration.CacheEventListenerFactoryConfiguration factory)

Used by BeanUtils to add cacheEventListenerFactory elements to the cache configuration.

public final void
addCacheExceptionHandlerFactory(CacheConfiguration.CacheExceptionHandlerFactoryConfiguration factory)

Add the CacheExceptionHandlerFactory to the configuration.

public final void
addCacheExtensionFactory(CacheConfiguration.CacheExtensionFactoryConfiguration factory)

Used by BeanUtils to add cacheExtensionFactory elements to the cache configuration.

public final void
addCacheLoaderFactory(CacheConfiguration.CacheLoaderFactoryConfiguration factory)

Used by BeanUtils to add each cacheLoaderFactory to the cache configuration.

public final void
addCacheWriter(CacheWriterConfiguration cacheWriterConfiguration)

Allows BeanHandler to add the CacheWriterConfiguration to the configuration.

public boolean

Returns:

true if a listener was added
addConfigurationListener
(CacheConfigurationListener
listener instance to add
listener
)

Add a listener to this cache configuration

public void
addCopyStrategy(CopyStrategyConfiguration
the CopyStrategy Configuration
copyStrategyConfiguration
)

Sets the CopyStrategyConfiguration for this cache

public boolean

Returns:

true if a listener was added
addDynamicSearchListener
(DynamicSearchListener listener)

Add a dynamic extractor configuration listener

public void
addElementValueComparator(ElementValueComparatorConfiguration
the ElementComparator Configuration
elementValueComparatorConfiguration
)

Sets the ElementValueComparatorConfiguration for this cache The default configuration will setup a net.sf.ehcache.store.DefaultElementValueComparator

public void
addPersistence(PersistenceConfiguration
the Persistence Configuration
persistenceConfiguration
)

Sets the PersistenceConfiguration for this cache.

public final void
addPinning(PinningConfiguration pinningConfiguration)

Allows BeanHandler to add the PinningConfiguration to the configuration.

public final void
addSearchable(Searchable
search config to add
searchable
)

Add configuration to make this cache searchable

public void
addSizeOfPolicy(SizeOfPolicyConfiguration
the SizeOfPolicy Configuration
sizeOfPolicyConfiguration
)

Sets the SizeOfPolicyConfiguration for this cache.

public final void
addTerracotta(TerracottaConfiguration terracottaConfiguration)

Allows BeanHandler to add the TerracottaConfiguration to the configuration.

private void
public final CacheConfiguration
public final CacheConfiguration
public final CacheConfiguration
public final CacheConfiguration
public final CacheConfiguration

Returns:

this configuration instance
cacheLoaderFactory
(CacheConfiguration.CacheLoaderFactoryConfiguration factory)

public final CacheConfiguration

Returns:

this configuration instance
cacheWriter
(CacheWriterConfiguration cacheWriterConfiguration)

private void
private void
checkIfCachePinned(long maxEntriesInCache)

public final CacheConfiguration

Returns:

this configuration instance
clearOnFlush
(boolean
true to clear on flush
clearOnFlush
)

Builder which sets whether the MemoryStore should be cleared when flush() is called on the cache - true by default.

public CacheConfiguration

Returns:

a copy, which independent other than configurations than cannot change.
clone
()

Overrides java.lang.Object.clone.

Clones this object, following the usual contract.
private void
private void
private void
private void
pack-priv void
configCachePools(Configuration
the Configuration of the CacheManager managing this cache
configuration
)

Configures the cache pools

private void
public CacheConfiguration
copyOnRead(boolean
true, if copyOnRead
copyOnRead
)

Whether the Cache should copy elements it returns

public CacheConfiguration
copyOnWrite(boolean
true, if copyOnWrite
copyOnWrite
)

Whether the Cache should copy elements it gets

public final CacheConfiguration

Returns:

this configuration instance
diskAccessStripes
(int stripes)

Builder which sets the number of disk stripes.

public final CacheConfiguration

Returns:

this configuration instance
diskExpiryThreadIntervalSeconds
(long diskExpiryThreadIntervalSeconds)

Builder which sets the interval in seconds between runs of the disk expiry thread.

public final CacheConfiguration

Returns:

this configuration instance
diskPersistent
(boolean
whether to persist the cache to disk between JVM restarts.
diskPersistent
)

Deprecated The diskPersistent attribute has been replaced with persistence(PersistenceConfiguration).
Builder which sets whether the disk store persists between CacheManager instances.
public final CacheConfiguration

Returns:

this configuration instance
diskSpoolBufferSizeMB
(int
a positive number
diskSpoolBufferSizeMB
)

Builder which sets the disk spool size, which is used to buffer writes to the DiskStore.

public CacheConfiguration

Returns:

this
dynamicAttributeExtractor
(DynamicAttributesExtractor
extractor to use
extractor
)

Sets dynamic search attributes extractor

public final CacheConfiguration

Returns:

this configuration instance
eternal
(boolean
true for eternal
eternal
)

Builder which sets whether elements are eternal.

private void
fireDiskCapacityChanged(int oldCapacity, int newCapacity)

private void
private void
fireLoggingChanged(boolean oldValue, boolean newValue)

private void
fireMaxBytesOnLocalDiskChanged(final Long oldValue, final Long newValue)

private void
fireMaxBytesOnLocalHeapChanged(final Long oldValue, final Long newValue)

private void
fireMaxEntriesInCacheChanged(long oldCapacity, long newCapacity)

private void
fireMemoryCapacityChanged(int oldCapacity, int newCapacity)

private void
fireTtiChanged(long oldTti, long newTti)

private void
fireTtlChanged(long oldTtl, long newTtl)

public void
freezeConfiguration()

Freeze this configuration.

private void
freezePoolUsages(final CacheManager cacheManager)

public CacheConfiguration.BootstrapCacheLoaderFactoryConfiguration

Returns:

the configuration
getBootstrapCacheLoaderFactoryConfiguration
()

Accessor

public List<CacheConfiguration.CacheDecoratorFactoryConfiguration>

Returns:

the configuration
getCacheDecoratorConfigurations
()

Accessor

public List<E>
public CacheConfiguration.CacheExceptionHandlerFactoryConfiguration

Returns:

the configuration
getCacheExceptionHandlerFactoryConfiguration
()

Accessor

public List<E>

Returns:

the configuration
getCacheExtensionConfigurations
()

Accessor

public List<E>

Returns:

the configuration
getCacheLoaderConfigurations
()

Accessor

public long
public CacheWriterConfiguration

Returns:

the writer configuration
getCacheWriterConfiguration
()

Accessor

public ClassLoader
public ReadWriteCopyStrategy<Element>

Returns:

the ReadWriteCopyStrategy for instance for this cache
getCopyStrategy
()

Getter to the configured ReadWriteCopyStrategy.

public CopyStrategyConfiguration

Returns:

the copyStrategyConfiguration
getCopyStrategyConfiguration
()

Returns the copyStrategyConfiguration

public int
public long
public int
public DynamicAttributesExtractor
public ElementValueComparatorConfiguration

Returns:

the elementComparatorConfiguration
getElementValueComparatorConfiguration
()

Returns the elementComparatorConfiguration

public boolean

Returns:

true if logging is enabled otherwise false
getLogging
()

Only used when cache is clustered with Terracotta

public long

Returns:

value in bytes, 0 if none set
getMaxBytesLocalDisk
()

The maximum amount of bytes the cache should occupy on disk

public String

Returns:

value as string in bytes
getMaxBytesLocalDiskAsString
()

The string form of the maximum amount of bytes the cache should occupy on disk

public Integer

Returns:

percentage (between 0 and 100)
getMaxBytesLocalDiskPercentage
()

Getter for maximum bytes on disk expressed as a percentage

public long

Returns:

value in bytes, 0 if none set
getMaxBytesLocalHeap
()

The maximum amount of bytes the cache should occupy on heap

public String

Returns:

value as string in bytes
getMaxBytesLocalHeapAsString
()

The string form of the maximum amount of bytes the cache should occupy on heap

public Integer

Returns:

percentage (between 0 and 100)
getMaxBytesLocalHeapPercentage
()

Getter for maximum bytes on heap expressed as a percentage

public long

Returns:

value in bytes, 0 if none set
getMaxBytesLocalOffHeap
()

The maximum amount of bytes the cache should occupy off heap

public String

Returns:

value as string in bytes
getMaxBytesLocalOffHeapAsString
()

The string form of the maximum amount of bytes the cache should occupy off heap

public Integer

Returns:

percentage (between 0 and 100)
getMaxBytesLocalOffHeapPercentage
()

Getter for maximum bytes off heap expressed as a percentage

public int
public int
getMaxElementsOnDisk()

Deprecated use getMaxEntriesLocalDisk() for unclustered caches and getMaxEntriesInCache() for clustered caches.
Accessor
public long
public long
getMaxEntriesLocalDisk()

Configured maximum number of entries for the local disk store.

public long
getMaxEntriesLocalHeap()

Configured maximum number of entries for the local memory heap.

public String

Returns:

the max memory of the offheap store for this cache.
getMaxMemoryOffHeap
()

Accessor
public long

Returns:

the max memory of the offheap store for this cache, in bytes.
getMaxMemoryOffHeapInBytes
()

Accessor
public MemoryStoreEvictionPolicy
public String
getName()

Accessor

public PersistenceConfiguration

Returns:

the persistence configuration for this cache.
getPersistenceConfiguration
()

Accessor

public PinningConfiguration

Returns:

the pinning configuration
getPinningConfiguration
()

Accessor

public Searchable

Returns:

search config (may be null)
getSearchable
()

Get the search configuration for this cache (if any)

public Map<String, SearchAttribute>

Returns:

search attributes
getSearchAttributes
()

Get the defined search attributes indexed by attribute name

public SizeOfPolicyConfiguration

Returns:

the SizeOfPolicy Configuration for this cache.
getSizeOfPolicyConfiguration
()

Accessor

public final boolean
getStatistics()

Gets whether the cache's statistics will be enabled at startup

public TerracottaConfiguration

Returns:

the terracotta configuration
getTerracottaConfiguration
()

Accessor

public TerracottaConfiguration.Consistency

Returns:

the CoherenceMode if Terracotta-clustered or null
getTerracottaConsistency
()

Accessor

public long
public long
public final CacheConfiguration.TransactionalMode

Returns:

transactionaMode
getTransactionalMode
()

To what transactionalMode was the Cache set

public void
internalSetDiskCapacity(int capacity)

Intended for internal use only, and subject to change.

public void
internalSetEternal(boolean eternal)

Intended for internal use only, and subject to change.

public void
internalSetLogging(boolean logging)

Intended for internal use only, and subject to change.

public void
internalSetMaxBytesLocalOffheap(long maxBytesLocalOffheap)

Intended for internal use only, and subject to change.

public void
internalSetMaxEntriesInCache(int entries)

Intended for internal use only, and subject to change.

public void
internalSetMemCapacity(int capacity)

Intended for internal use only, and subject to change.

public void
internalSetMemCapacityInBytes(long capacity)

Intended for internal use only, and subject to change.

public void
internalSetOverflowToOffheap(boolean overflowToOffHeap)

Intended for internal use only, and subject to change.

public void
internalSetTimeToIdle(long timeToIdle)

Intended for internal use only, and subject to change.

public void
internalSetTimeToLive(long timeToLive)

Intended for internal use only, and subject to change.

public boolean
isClearOnFlush()

Accessor

public boolean

Returns:

true, is copyOnRead
isCopyOnRead
()

Whether the Cache should copy elements it returns

public boolean

Returns:

true, if copyOnWrite
isCopyOnWrite
()

Whether the Cache should copy elements it gets

public boolean

Returns:

true if maxEntries set, false otherwise
isCountBasedTuned
()

Whether this cache is Count based

public boolean
isDiskPersistent()

Deprecated The diskPersistent attribute has been replaced with persistence(PersistenceConfiguration).
Accessor
public boolean
isEternal()

Accessor

private boolean
isEternalValueConflictingWithTTIOrTTL(boolean newEternalValue, long newTTLValue, long newTTIValue)

public boolean

Returns:

true is this configuration is frozen - it cannot be changed dynamically.
isFrozen
()

public boolean

Returns:

true if transactionalMode="local"
isLocalTransactional
()

Helper method to compute whether the cache is local transactional or not

public boolean

Returns:

true if set by user, false otherwise
isMaxBytesLocalDiskPercentageSet
()

Checks whether the user explicitly set the maxBytesOnDiskPercentage

public boolean

Returns:

true if set by user, false otherwise
isMaxBytesLocalHeapPercentageSet
()

Checks whether the user explicitly set the maxBytesOnHeapPercentage

public boolean

Returns:

true if set by user, false otherwise
isMaxBytesLocalOffHeapPercentageSet
()

Checks whether the user explicitly set the maxBytesOffHeapPercentage

public boolean
isOverflowToDisk()

Deprecated The overflowToDisk attribute has been replaced with Strategy#LOCALTEMPSWAP.
Accessor
public boolean

Returns:

true if offheap store is enabled, otherwise false.
isOverflowToOffHeap
()

Accessor

public boolean

Returns:

true if explicitly set, false otherwise
isOverflowToOffHeapSet
()

Checks whether the overflowing to off heap behavior was explicitly set

private boolean
isPercentage(final String stringValue)

public boolean
isSearchable()

Accessor

public boolean

Returns:

True if the <terracotta/> element exists with clustered="true"
isTerracottaClustered
()

Helper method to compute whether the cache is clustered or not

public boolean

Returns:

true if transactionalMode="xa_strict"
isXaStrictTransactional
()

Helper method to compute whether the cache is XA transactional or not

public boolean

Returns:

true if transactionalMode="xa"
isXaTransactional
()

Helper method to compute whether the cache is local_jta transactional or not

public final CacheConfiguration

Returns:

this configuration instance
logging
(boolean
If true, enables logging otherwise disables logging
enable
)

Builder to enable or disable logging for the cache

This property can be modified dynamically while the cache is operating.

public CacheConfiguration

Returns:

this
maxBytesLocalDisk
(final long
the amount of unit
amount
,
final MemoryUnit
the actual unit
memoryUnit
)

Sets the maxOnDisk size

This property can be modified dynamically while the cache is operating.

public CacheConfiguration

Returns:

this
maxBytesLocalHeap
(final long
the amount of unit
amount
,
final MemoryUnit
the actual unit
memoryUnit
)

Sets the maxOnHeap size

public CacheConfiguration

Returns:

this
maxBytesLocalOffHeap
(final long
the amount of unit
amount
,
final MemoryUnit
the actual unit
memoryUnit
)

Sets the maxOffHeap tier size

Changes to this property once the cache is operating will have no effect.

public final CacheConfiguration

Returns:

this configuration instance
maxElementsInMemory
(int
The maximum number of elements in memory, before they are evicted (0 == no limit)
maxElementsInMemory
)

Deprecated use maxEntriesLocalHeap(int)
Builder that sets the maximum objects to be held in memory (0 = no limit).
public final CacheConfiguration

Returns:

this configuration instance
maxElementsOnDisk
(int
the maximum number of Elements to allow on the disk. 0 means unlimited.
maxElementsOnDisk
)

Deprecated use maxEntriesLocalDisk(int) for unclustered caches and maxEntriesInCache(long) for clustered caches.
Builder which sets the maximum number elements on Disk.
public final CacheConfiguration

Returns:

this configuration instance
maxEntriesInCache
(long
the maximum number of entries to allow in the cache.
maxEntriesInCache
)

Builder which sets the maximum number entries in cache.

public final CacheConfiguration

Returns:

this configuration instance
maxEntriesLocalDisk
(int
the maximum number of Elements to allow on the disk. 0 means unlimited.
maxElementsOnDisk
)

Builder which sets the maximum number elements on Disk.

public final CacheConfiguration

Returns:

this configuration instance
maxEntriesLocalHeap
(int
The maximum number of elements in memory, before they are evicted (0 == no limit)
maxElementsInMemory
)

Builder that sets the maximum objects to be held in memory (0 = no limit).

public CacheConfiguration

Returns:

this configuration instance
maxMemoryOffHeap
(String
the max off heap memory size allocated for this cache.
maxMemoryOffHeap
)

Builder to set the max off heap memory size allocated for this cache.
public final CacheConfiguration

Returns:

this configuration instance
memoryStoreEvictionPolicy
(String
a String representation of the policy. One of "LRU", "LFU" or "FIFO".
memoryStoreEvictionPolicy
)

Builder that sets the eviction policy.

public final CacheConfiguration

Returns:

this configuration instance
memoryStoreEvictionPolicy
(MemoryStoreEvictionPolicy memoryStoreEvictionPolicy)

Builder which Sets the eviction policy.

public final CacheConfiguration

Returns:

this configuration instance
name
(String
the cache name. This must be unique.
name
)

Builder to set the name of the cache.

public final CacheConfiguration

Returns:

this configuration instance
overflowToDisk
(boolean
whether to use the disk store
overflowToDisk
)

Deprecated The overflowToDisk attribute has been replaced with Strategy#LOCALTEMPSWAP.
Builder which sets whether elements can overflow to disk when the in-memory cache has reached the set limit.
public CacheConfiguration

Returns:

this configuration instance
overflowToOffHeap
(boolean
If true, enables offheap store otherwise disables it.
overflowToOffHeap
)

Builder to enable or disable offheap store for the cache.

private int
parsePercentage(final String stringValue)

public CacheConfiguration

Returns:

this configuration instance
persistence
(PersistenceConfiguration
the Persistence Configuration
persistenceConfiguration
)

Builder to set the PersistenceConfiguration for this cache.

public final CacheConfiguration

Returns:

this configuration instance
pinning
(PinningConfiguration pinningConfiguration)

private void
public boolean

Returns:

true if a listener was removed
removeConfigurationListener
(CacheConfigurationListener
listener to remove
listener
)

Remove the supplied cache configuration listener.

public final CacheConfiguration

Returns:

this
searchable
(Searchable searchable)

public final void
setCacheLoaderTimeoutMillis(long
the timeout in milliseconds.
cacheLoaderTimeoutMillis
)

Sets the timeout for CacheLoader execution (0 = no timeout).

public void
public final void
setClearOnFlush(boolean
true to clear on flush
clearOnFlush
)

Sets whether the MemoryStore should be cleared when flush() is called on the cache - true by default.

public void
setCopyOnRead(final boolean
true, if copyOnRead
copyOnRead
)

Whether the Cache should copy elements it returns

public void
setCopyOnWrite(final boolean
true, if copyOnWrite
copyOnWrite
)

Whether the Cache should copy elements it gets

public void
setDiskAccessStripes(int
number of stripes (rounded up to a power-of-2)
stripes
)

Sets the number of disk stripes.

public final void
setDiskExpiryThreadIntervalSeconds(long diskExpiryThreadIntervalSeconds)

Sets the interval in seconds between runs of the disk expiry thread.

public final void
setDiskPersistent(boolean
whether to persist the cache to disk between JVM restarts
diskPersistent
)

Deprecated The diskPersistent attribute has been replaced with persistence(PersistenceConfiguration).
Sets whether the disk store persists between CacheManager instances.
public void
setDiskSpoolBufferSizeMB(int
a positive number
diskSpoolBufferSizeMB
)

Sets the disk spool size, which is used to buffer writes to the DiskStore.

public void
setDynamicAttributesExtractor(DynamicAttributesExtractor
extractor to use
extractor
)

Sets dynamic search attributes extractor

public final void
setEternal(boolean
true for eternal
eternal
)

Sets whether elements are eternal.

public final void
setLogging(boolean
If true, enables logging otherwise disables logging
enable
)

Enables or disables logging for the cache

This property can be modified dynamically while the cache is operating.

public void
setMaxBytesLocalDisk(final String
String representation of the size, can be relative (in %)
maxBytesDisk
)

Setter for maxBytesOnDisk as a String.

public void
setMaxBytesLocalDisk(final Long
max bytes on disk in bytes
maxBytesDisk
)

Sets the maximum amount of bytes the cache being configured will use on the OnDisk tier

This property can be modified dynamically while the cache is operating.

public void
setMaxBytesLocalHeap(final String
String representation of the size, can be relative (in %)
maxBytesHeap
)

Setter for maxBytesLocalHeap as a String.

public void
setMaxBytesLocalHeap(final Long
max bytes in heap in bytes
maxBytesHeap
)

Setter for maxBytesLocalHeap in bytes

This property can be modified dynamically while the cache is operating.

public void
setMaxBytesLocalOffHeap(final String
String representation of the size, can be relative (in %)
maxBytesOffHeap
)

Setter for maximum bytes off heap as a String.

public void
setMaxBytesLocalOffHeap(final Long
max bytes on disk in bytes
maxBytesOffHeap
)

Sets the maximum amount of bytes the cache being configured will use on the OffHeap tier

Changes to this property once the cache is operating will have no effect.

public final void
setMaxElementsInMemory(int
The maximum number of elements in memory, before they are evicted (0 == no limit)
maxElementsInMemory
)

Sets the maximum objects to be held in memory (0 = no limit).
public void
setMaxElementsOnDisk(int
the maximum number of Elements to allow on the disk. 0 means unlimited.
maxElementsOnDisk
)

Deprecated use setMaxEntriesLocalDisk(long) for unclustered caches and setMaxEntriesInCache(long) for clustered caches.
Sets the maximum number elements on Disk.
public void
setMaxEntriesInCache(long
maximum number of entries in cache
maxEntriesInCache
)

Sets the maximum number of entries in the cache.

public void
setMaxEntriesLocalDisk(long
the maximum number of Elements to allow on the disk. 0 means unlimited.
maxEntriesLocalDisk
)

Sets the maximum number elements on Disk.

public final void
setMaxEntriesLocalHeap(long
The maximum number of elements in memory, before they are evicted (0 == no limit)
maxEntriesLocalHeap
)

Sets the maximum objects to be held in local heap memory (0 = no limit).

public final void
setMaxMemoryOffHeap(String
the max off heap memory size allocated for this cache.
maxMemoryOffHeap
)

Sets the max off heap memory size allocated for this cache.
public final void
setMemoryStoreEvictionPolicy(String
a String representation of the policy. One of "LRU", "LFU" or "FIFO".
memoryStoreEvictionPolicy
)

Sets the eviction policy.

public final void
setMemoryStoreEvictionPolicyFromObject(MemoryStoreEvictionPolicy memoryStoreEvictionPolicy)

Sets the eviction policy.

public final void
setName(String
the cache name. This must be unique.
name
)

Sets the name of the cache.

public final void
setOverflowToDisk(boolean
whether to use the disk store
overflowToDisk
)

Deprecated The overflowToDisk attribute has been replaced with Strategy#LOCALTEMPSWAP.
Sets whether elements can overflow to disk when the in-memory cache has reached the set limit.
public final void
setOverflowToOffHeap(boolean
If true, enables offheap store otherwise disables it.
overflowToOffHeap
)

Enables or disables offheap store for the cache.

public final void
setStatistics(boolean enabled)

Deprecated
Sets whether the cache's statistics are enabled.
public final void
setTimeToIdleSeconds(long
the default amount of time to live for an element from its last accessed or modified date
timeToIdleSeconds
)

Sets the time to idle for an element before it expires.

public final void
setTimeToLiveSeconds(long
the default amount of time to live for an element from its creation date
timeToLiveSeconds
)

Sets the time to idle for an element before it expires.

public final void
setTransactionalMode(final String
one of OFF, LOCAL, XA, XA_STRICT
transactionalMode
)

Sets the transactionalMode

public void
setupFor(final CacheManager
The CacheManager as part of which the cache is being setup
cacheManager
)

Sets up the CacheConfiguration for runtime consumption, also registers this cache configuration with the cache manager's configuration

public void
setupFor(final CacheManager
The CacheManager as part of which the cache is being setup
cacheManager
,
final boolean
true to register this cache configuration with the cache manager.
register
,
final String parentCache)

Sets up the CacheConfiguration for runtime consumption

public CacheConfiguration

Returns:

this configuration instance
sizeOfPolicy
(SizeOfPolicyConfiguration
the SizeOfPolicy Configuration
sizeOfPolicyConfiguration
)

Builder to set the SizeOfPolicyConfiguration for this cache.

public final CacheConfiguration

Returns:

this configuration instance
statistics
(boolean statistics)

Deprecated
Builder which sets whether the cache's statistics are enabled.
public final CacheConfiguration

Returns:

this configuration instance
terracotta
(TerracottaConfiguration terracottaConfiguration)

public CacheConfiguration

Returns:

this configuration instance
timeoutMillis
(long
the timeout in milliseconds.
timeoutMillis
)

Builder that sets the timeout for CacheLoader execution (0 = no timeout).

public final CacheConfiguration

Returns:

this configuration instance
timeToIdleSeconds
(long
the default amount of time to live for an element from its last accessed or modified date
timeToIdleSeconds
)

Builder which sets the time to idle for an element before it expires.

public final CacheConfiguration

Returns:

this configuration instance
timeToLiveSeconds
(long
the default amount of time to live for an element from its creation date
timeToLiveSeconds
)

Builder which sets the time to idle for an element before it expires.

public final CacheConfiguration

Returns:

this configuration instance
transactionalMode
(String
one of OFF, LOCAL, XA, XA_STRICT
transactionalMode
)

Builder which sets the transactionalMode

public final CacheConfiguration

Returns:

this configuration instance
transactionalMode
(CacheConfiguration.TransactionalMode
one of OFF, LOCAL, XA, XA_STRICT
transactionalMode
)

Builder which sets the transactionalMode

private void
public Collection<ConfigError>

Returns:

the errors in the config
validate
(final Configuration
the CacheManager configuration this is going to be used with
configuration
)

Validates the configuration

pack-priv List<CacheConfigError>

Returns:

the list of errors encountered, or an empty list
validateCachePools
(final Configuration
The CacheManager Configuration
configuration
)

Validates the CacheConfiguration against the CacheManager's Configuration

public void
validateCompleteConfiguration()

Used to validate what should be a complete Cache Configuration.

public void
validateConfiguration()

Used to validate a Cache Configuration.

private void
private void
private void
verifyGreaterThanOrEqualToZero(final Long fieldVal, final String fieldName)

private void
verifyGreaterThanZero(final Long fieldVal, final String fieldName)

private void
verifyLocalDisk(final long managerMaxBytesLocalDisk, final List<ConfigError> configErrors, final long totalOnDiskAssignedMemory)

private void
verifyLocalHeap(final long managerMaxBytesLocalHeap, final List<ConfigError> configErrors, final long totalOnHeapAssignedMemory)

private void
verifyLocalOffHeap(final long managerMaxBytesLocalOffHeap, final List<ConfigError> configErrors, final long totalOffHeapAssignedMemory)

pack-priv List<ConfigError>

Returns:

a list with potential errors
verifyPoolAllocationsBeforeAddingTo
(CacheManager
The cacheManager that will manage the cache
cacheManager
,
long
bytes for local heap
managerMaxBytesLocalHeap
,
long
bytes for local offheap
managerMaxBytesLocalOffHeap
,
long
bytes for local disk
managerMaxBytesLocalDisk
,
String
cacheName for parentCache to be used when initializing shadow caches
parentCacheName
)

Will verify that we don't overallocate pools

private void
warnMaxEntriesForOverflowToOffHeap(final boolean register)

private void
warnMaxEntriesLocalHeap(final boolean register, CacheManager cacheManager)

private void
private void
Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait