ehcache

net.sf.ehcache.config
Class CacheConfiguration

java.lang.Object
  extended bynet.sf.ehcache.config.CacheConfiguration

public final class CacheConfiguration
extends java.lang.Object

A class to represent Cache configuration. e.g.

Version:
$Id: CacheConfiguration.java 52 2006-04-24 14:50:03Z gregluck $
Author:
Greg Luck

Nested Class Summary
 class CacheConfiguration.CacheEventListenerFactoryConfiguration
          Configuration for the CachePeerListenerFactoryConfiguration.
 
Field Summary
protected  java.util.List cacheEventListenerConfigurations
          The event listener factories added by BeanUtils.
protected  long diskExpiryThreadIntervalSeconds
          The interval in seconds between runs of the disk expiry thread.
protected  boolean diskPersistent
          For caches that overflow to disk, whether the disk cache persists between CacheManager instances.
protected  boolean eternal
          Sets whether elements are eternal.
protected  int maxElementsInMemory
          the maximum objects to be held in the MemoryStore.
protected  MemoryStoreEvictionPolicy memoryStoreEvictionPolicy
          The policy used to evict elements from the MemoryStore.
protected  java.lang.String name
          the name of the cache.
protected  boolean overflowToDisk
          whether elements can overflow to disk when the in-memory cache has reached the set limit.
protected  int timeToIdleSeconds
          the time to idle for an element before it expires.
protected  int timeToLiveSeconds
          Sets the time to idle for an element before it expires.
 
Constructor Summary
CacheConfiguration()
           
 
Method Summary
 void addCacheEventListenerFactory(CacheConfiguration.CacheEventListenerFactoryConfiguration factory)
          Used by BeanUtils to add cacheEventListenerFactory elements to the cache configuration.
 void setDiskExpiryThreadIntervalSeconds(int diskExpiryThreadIntervalSeconds)
          Sets the interval in seconds between runs of the disk expiry thread.
 void setDiskPersistent(boolean diskPersistent)
          Sets whether, for caches that overflow to disk, the disk cache persist between CacheManager instances.
 void setEternal(boolean eternal)
          Sets whether elements are eternal.
 void setMaxElementsInMemory(int maxElementsInMemory)
          Sets the maximum objects to be held in memory.
 void setMemoryStoreEvictionPolicy(java.lang.String memoryStoreEvictionPolicy)
          Sets the eviction policy.
 void setName(java.lang.String name)
          Sets the name of the cache.
 void setOverflowToDisk(boolean overflowToDisk)
          Sets whether elements can overflow to disk when the in-memory cache has reached the set limit.
 void setTimeToIdleSeconds(int timeToIdleSeconds)
          Sets the time to idle for an element before it expires.
 void setTimeToLiveSeconds(int timeToLiveSeconds)
          Sets the time to idle for an element before it expires.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
the name of the cache.


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

eternal

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


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.


overflowToDisk

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


diskPersistent

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


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.


cacheEventListenerConfigurations

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

Constructor Detail

CacheConfiguration

public CacheConfiguration()
Method Detail

setName

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


setMaxElementsInMemory

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


setMemoryStoreEvictionPolicy

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


setEternal

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


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.


setOverflowToDisk

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


setDiskPersistent

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


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.


addCacheEventListenerFactory

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


ehcache

true