net.sf.ehcache.config

Class CacheConfiguration

public class CacheConfiguration extends Object

A class to represent Cache configuration. e.g.

Version: $Id: CacheConfiguration.java 147 2006-07-04 09:02:07Z gregluck $

Author: Greg Luck

Nested Class Summary
classCacheConfiguration.BootstrapCacheLoaderFactoryConfiguration
Configuration for the BootstrapCacheLoaderFactoryConfiguration.
classCacheConfiguration.CacheEventListenerFactoryConfiguration
Configuration for the CachePeerListenerFactoryConfiguration.
Field Summary
protected CacheConfiguration.BootstrapCacheLoaderFactoryConfigurationbootstrapCacheLoaderFactoryConfiguration
The BootstrapCacheLoaderFactoryConfiguration.
protected ListcacheEventListenerConfigurations
The event listener factories added by BeanUtils.
protected longdiskExpiryThreadIntervalSeconds
The interval in seconds between runs of the disk expiry thread.
protected booleandiskPersistent
For caches that overflow to disk, whether the disk cache persists between CacheManager instances.
protected booleaneternal
Sets whether elements are eternal.
protected intmaxElementsInMemory
the maximum objects to be held in the MemoryStore.
protected MemoryStoreEvictionPolicymemoryStoreEvictionPolicy
The policy used to evict elements from the MemoryStore.
protected Stringname
the name of the cache.
protected booleanoverflowToDisk
whether elements can overflow to disk when the in-memory cache has reached the set limit.
protected inttimeToIdleSeconds
the time to idle for an element before it expires.
protected inttimeToLiveSeconds
Sets the time to idle for an element before it expires.
Method Summary
voidaddBootstrapCacheLoaderFactory(CacheConfiguration.BootstrapCacheLoaderFactoryConfiguration bootstrapCacheLoaderFactoryConfiguration)
Allows BeanHandler to add the CacheManagerEventListener to the configuration.
voidaddCacheEventListenerFactory(CacheConfiguration.CacheEventListenerFactoryConfiguration factory)
Used by BeanUtils to add cacheEventListenerFactory elements to the cache configuration.
CacheConfiguration.BootstrapCacheLoaderFactoryConfigurationgetBootstrapCacheLoaderFactoryConfiguration()
Accessor
ListgetCacheEventListenerConfigurations()
Accessor
longgetDiskExpiryThreadIntervalSeconds()
Accessor
intgetMaxElementsInMemory()
Accessor
MemoryStoreEvictionPolicygetMemoryStoreEvictionPolicy()
Accessor
StringgetName()
Accessor
intgetTimeToIdleSeconds()
Accessor
intgetTimeToLiveSeconds()
Accessor
booleanisDiskPersistent()
Accessor
booleanisEternal()
Accessor
booleanisOverflowToDisk()
Accessor
voidsetDiskExpiryThreadIntervalSeconds(int diskExpiryThreadIntervalSeconds)
Sets the interval in seconds between runs of the disk expiry thread.
voidsetDiskPersistent(boolean diskPersistent)
Sets whether, for caches that overflow to disk, the disk cache persist between CacheManager instances.
voidsetEternal(boolean eternal)
Sets whether elements are eternal.
voidsetMaxElementsInMemory(int maxElementsInMemory)
Sets the maximum objects to be held in memory.
voidsetMemoryStoreEvictionPolicy(String memoryStoreEvictionPolicy)
Sets the eviction policy.
voidsetName(String name)
Sets the name of the cache.
voidsetOverflowToDisk(boolean overflowToDisk)
Sets whether elements can overflow to disk when the in-memory cache has reached the set limit.
voidsetTimeToIdleSeconds(int timeToIdleSeconds)
Sets the time to idle for an element before it expires.
voidsetTimeToLiveSeconds(int timeToLiveSeconds)
Sets the time to idle for an element before it expires.

Field Detail

bootstrapCacheLoaderFactoryConfiguration

protected CacheConfiguration.BootstrapCacheLoaderFactoryConfiguration bootstrapCacheLoaderFactoryConfiguration
The BootstrapCacheLoaderFactoryConfiguration.

cacheEventListenerConfigurations

protected final List cacheEventListenerConfigurations
The event listener factories added by BeanUtils.

diskExpiryThreadIntervalSeconds

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

2 minutes is the default. This is not the same thing as time to live or time to idle. When the thread runs it checks these things. So this value is how often we check for expiry.

diskPersistent

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

eternal

protected boolean eternal
Sets whether elements are eternal. If eternal, timeouts are ignored and the element is never expired.

maxElementsInMemory

protected int maxElementsInMemory
the maximum objects to be held in the MemoryStore.

memoryStoreEvictionPolicy

protected MemoryStoreEvictionPolicy memoryStoreEvictionPolicy
The policy used to evict elements from the MemoryStore. This can be one of:
  1. LRU - least recently used
  2. LFU - Less frequently used
  3. FIFO - first in first out, the oldest element by creation time
The default value is LRU

Since: 1.2

name

protected String name
the name of the cache.

overflowToDisk

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

timeToIdleSeconds

protected int timeToIdleSeconds
the time to idle for an element before it expires. Is only used if the element is not eternal.A value of 0 means do not check for idling.

timeToLiveSeconds

protected int timeToLiveSeconds
Sets the time to idle for an element before it expires. Is only used if the element is not eternal. This attribute is optional in the configuration. A value of 0 means do not check time to live.

Method Detail

addBootstrapCacheLoaderFactory

public final void addBootstrapCacheLoaderFactory(CacheConfiguration.BootstrapCacheLoaderFactoryConfiguration bootstrapCacheLoaderFactoryConfiguration)
Allows BeanHandler to add the CacheManagerEventListener to the configuration.

addCacheEventListenerFactory

public final void addCacheEventListenerFactory(CacheConfiguration.CacheEventListenerFactoryConfiguration factory)
Used by BeanUtils to add cacheEventListenerFactory elements to the cache configuration.

getBootstrapCacheLoaderFactoryConfiguration

public CacheConfiguration.BootstrapCacheLoaderFactoryConfiguration getBootstrapCacheLoaderFactoryConfiguration()
Accessor

getCacheEventListenerConfigurations

public List getCacheEventListenerConfigurations()
Accessor

getDiskExpiryThreadIntervalSeconds

public long getDiskExpiryThreadIntervalSeconds()
Accessor

getMaxElementsInMemory

public int getMaxElementsInMemory()
Accessor

getMemoryStoreEvictionPolicy

public MemoryStoreEvictionPolicy getMemoryStoreEvictionPolicy()
Accessor

getName

public String getName()
Accessor

getTimeToIdleSeconds

public int getTimeToIdleSeconds()
Accessor

getTimeToLiveSeconds

public int getTimeToLiveSeconds()
Accessor

isDiskPersistent

public boolean isDiskPersistent()
Accessor

isEternal

public boolean isEternal()
Accessor

isOverflowToDisk

public boolean isOverflowToDisk()
Accessor

setDiskExpiryThreadIntervalSeconds

public final void setDiskExpiryThreadIntervalSeconds(int diskExpiryThreadIntervalSeconds)
Sets the interval in seconds between runs of the disk expiry thread.

2 minutes is the default. This is not the same thing as time to live or time to idle. When the thread runs it checks these things. So this value is how often we check for expiry.

setDiskPersistent

public final void setDiskPersistent(boolean diskPersistent)
Sets whether, for caches that overflow to disk, the disk cache persist between CacheManager instances.

setEternal

public final void setEternal(boolean eternal)
Sets whether elements are eternal. If eternal, timeouts are ignored and the element is never expired.

setMaxElementsInMemory

public final void setMaxElementsInMemory(int maxElementsInMemory)
Sets the maximum objects to be held in memory.

setMemoryStoreEvictionPolicy

public final void setMemoryStoreEvictionPolicy(String memoryStoreEvictionPolicy)
Sets the eviction policy. An invalid argument will set it to null.

setName

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

setOverflowToDisk

public final void setOverflowToDisk(boolean overflowToDisk)
Sets whether elements can overflow to disk when the in-memory cache has reached the set limit.

setTimeToIdleSeconds

public final void setTimeToIdleSeconds(int timeToIdleSeconds)
Sets the time to idle for an element before it expires. Is only used if the element is not eternal.

setTimeToLiveSeconds

public final void setTimeToLiveSeconds(int timeToLiveSeconds)
Sets the time to idle for an element before it expires. Is only used if the element is not eternal.