ehcache

net.sf.ehcache.config
Class CacheConfiguration

java.lang.Object
  extended by net.sf.ehcache.config.CacheConfiguration
All Implemented Interfaces:
java.lang.Cloneable

public class CacheConfiguration
extends java.lang.Object
implements java.lang.Cloneable

A value object to represent Cache configuration that can be set by the BeanHandler. e.g.

Version:
$Id: CacheConfiguration.java 704 2008-07-13 00:17:52Z gregluck $
Author:
Greg Luck

Nested Class Summary
 class CacheConfiguration.BootstrapCacheLoaderFactoryConfiguration
          Configuration for the BootstrapCacheLoaderFactoryConfiguration.
 class CacheConfiguration.CacheEventListenerFactoryConfiguration
          Configuration for the CachePeerListenerFactoryConfiguration.
 class CacheConfiguration.CacheExceptionHandlerFactoryConfiguration
          Configuration for the BootstrapCacheLoaderFactoryConfiguration.
 class CacheConfiguration.CacheExtensionFactoryConfiguration
          Configuration for the CacheExtensionFactoryConfiguration.
 class CacheConfiguration.CacheLoaderFactoryConfiguration
          Configuration for the CacheLoaderFactoryConfiguration.
 
Field Summary
protected  CacheConfiguration.BootstrapCacheLoaderFactoryConfiguration bootstrapCacheLoaderFactoryConfiguration
          The BootstrapCacheLoaderFactoryConfiguration.
protected  java.util.List cacheEventListenerConfigurations
          The event listener factories added by BeanUtils.
protected  CacheConfiguration.CacheExceptionHandlerFactoryConfiguration cacheExceptionHandlerFactoryConfiguration
          The CacheExceptionHandlerFactoryConfiguration.
protected  java.util.List cacheExtensionConfigurations
          The cache extension factories added by BeanUtils.
protected  CacheConfiguration.CacheLoaderFactoryConfiguration cacheLoaderFactoryConfiguration
          The CacheLoaderFactoryConfiguration.
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  int diskSpoolBufferSizeMB
          The size of the disk spool used to buffer writes
protected  boolean eternal
          Sets whether elements are eternal.
protected  int maxElementsInMemory
          the maximum objects to be held in the MemoryStore.
protected  int maxElementsOnDisk
          the maximum objects to be held in the DiskStore.
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  long timeToIdleSeconds
          the time to idle for an element before it expires.
protected  long timeToLiveSeconds
          Sets the time to idle for an element before it expires.
 
Constructor Summary
CacheConfiguration()
           
 
Method Summary
 void addBootstrapCacheLoaderFactory(CacheConfiguration.BootstrapCacheLoaderFactoryConfiguration bootstrapCacheLoaderFactoryConfiguration)
          Allows BeanHandler to add the CacheManagerEventListener to the configuration.
 void addCacheEventListenerFactory(CacheConfiguration.CacheEventListenerFactoryConfiguration factory)
          Used by BeanUtils to add cacheEventListenerFactory elements to the cache configuration.
 void addCacheExceptionHandlerFactory(CacheConfiguration.CacheExceptionHandlerFactoryConfiguration cacheExceptionHandlerFactoryConfiguration)
          Allows BeanHandler to add the CacheExceptionHandlerFactory to the configuration.
 void addCacheExtensionFactory(CacheConfiguration.CacheExtensionFactoryConfiguration factory)
          Used by BeanUtils to add cacheExtensionFactory elements to the cache configuration.
 void addCacheLoaderFactory(CacheConfiguration.CacheLoaderFactoryConfiguration cacheLoaderFactoryConfiguration)
          Allows BeanHandler to add the CacheLoaderFactory to the configuration.
 java.lang.Object clone()
          Clones this object, following the usual contract.
 CacheConfiguration.BootstrapCacheLoaderFactoryConfiguration getBootstrapCacheLoaderFactoryConfiguration()
          Accessor
 java.util.List getCacheEventListenerConfigurations()
          Accessor
 CacheConfiguration.CacheExceptionHandlerFactoryConfiguration getCacheExceptionHandlerFactoryConfiguration()
          Accessor
 java.util.List getCacheExtensionConfigurations()
          Accessor
 CacheConfiguration.CacheLoaderFactoryConfiguration getCacheLoaderFactoryConfiguration()
          Accessor
 long getDiskExpiryThreadIntervalSeconds()
          Accessor
 int getDiskSpoolBufferSizeMB()
          Getter
 int getMaxElementsInMemory()
          Accessor
 int getMaxElementsOnDisk()
          Accessor
 MemoryStoreEvictionPolicy getMemoryStoreEvictionPolicy()
          Accessor
 java.lang.String getName()
          Accessor
 long getTimeToIdleSeconds()
          Accessor
 long getTimeToLiveSeconds()
          Accessor
 boolean isDiskPersistent()
          Accessor
 boolean isEternal()
          Accessor
 boolean isOverflowToDisk()
          Accessor
 void setDiskExpiryThreadIntervalSeconds(long 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 setDiskSpoolBufferSizeMB(int diskSpoolBufferSizeMB)
          Sets the disk spool size
 void setEternal(boolean eternal)
          Sets whether elements are eternal.
 void setMaxElementsInMemory(int maxElementsInMemory)
          Sets the maximum objects to be held in memory.
 void setMaxElementsOnDisk(int maxElementsOnDisk)
          Sets the maximum number elements on Disk.
 void setMemoryStoreEvictionPolicy(java.lang.String memoryStoreEvictionPolicy)
          Sets the eviction policy.
 void setMemoryStoreEvictionPolicyFromObject(MemoryStoreEvictionPolicy 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(long timeToIdleSeconds)
          Sets the time to idle for an element before it expires.
 void setTimeToLiveSeconds(long timeToLiveSeconds)
          Sets the time to idle for an element before it expires.
 
Methods inherited from class java.lang.Object
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.


maxElementsOnDisk

protected int maxElementsOnDisk
the maximum objects to be held in the DiskStore.


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 long 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 long 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.


diskSpoolBufferSizeMB

protected int diskSpoolBufferSizeMB
The size of the disk spool used to buffer writes


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.


cacheExtensionConfigurations

protected final java.util.List cacheExtensionConfigurations
The cache extension factories added by BeanUtils.


bootstrapCacheLoaderFactoryConfiguration

protected CacheConfiguration.BootstrapCacheLoaderFactoryConfiguration bootstrapCacheLoaderFactoryConfiguration
The BootstrapCacheLoaderFactoryConfiguration.


cacheExceptionHandlerFactoryConfiguration

protected CacheConfiguration.CacheExceptionHandlerFactoryConfiguration cacheExceptionHandlerFactoryConfiguration
The CacheExceptionHandlerFactoryConfiguration.


cacheLoaderFactoryConfiguration

protected CacheConfiguration.CacheLoaderFactoryConfiguration cacheLoaderFactoryConfiguration
The CacheLoaderFactoryConfiguration.

Constructor Detail

CacheConfiguration

public CacheConfiguration()
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clones this object, following the usual contract.

Overrides:
clone in class java.lang.Object
Returns:
a copy, which independent other than configurations than cannot change.
Throws:
java.lang.CloneNotSupportedException

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.

Parameters:
memoryStoreEvictionPolicy - a String representation of the policy. One of "LRU", "LFU" or "FIFO".

setMemoryStoreEvictionPolicyFromObject

public final void setMemoryStoreEvictionPolicyFromObject(MemoryStoreEvictionPolicy memoryStoreEvictionPolicy)
Sets the eviction policy. This method has a strange name to workaround a problem with XML parsing.


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(long 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(long 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.


getDiskSpoolBufferSizeMB

public int getDiskSpoolBufferSizeMB()
Getter


setDiskSpoolBufferSizeMB

public void setDiskSpoolBufferSizeMB(int diskSpoolBufferSizeMB)
Sets the disk spool size

Parameters:
diskSpoolBufferSizeMB - a postive number

setMaxElementsOnDisk

public void setMaxElementsOnDisk(int maxElementsOnDisk)
Sets the maximum number elements on Disk. 0 means unlimited.


setDiskExpiryThreadIntervalSeconds

public final void setDiskExpiryThreadIntervalSeconds(long 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.


addCacheExtensionFactory

public final void addCacheExtensionFactory(CacheConfiguration.CacheExtensionFactoryConfiguration factory)
Used by BeanUtils to add cacheExtensionFactory elements to the cache configuration.


addBootstrapCacheLoaderFactory

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


addCacheExceptionHandlerFactory

public final void addCacheExceptionHandlerFactory(CacheConfiguration.CacheExceptionHandlerFactoryConfiguration cacheExceptionHandlerFactoryConfiguration)
Allows BeanHandler to add the CacheExceptionHandlerFactory to the configuration.


addCacheLoaderFactory

public final void addCacheLoaderFactory(CacheConfiguration.CacheLoaderFactoryConfiguration cacheLoaderFactoryConfiguration)
Allows BeanHandler to add the CacheLoaderFactory to the configuration.


getName

public java.lang.String getName()
Accessor


getMaxElementsInMemory

public int getMaxElementsInMemory()
Accessor


getMaxElementsOnDisk

public int getMaxElementsOnDisk()
Accessor


getMemoryStoreEvictionPolicy

public MemoryStoreEvictionPolicy getMemoryStoreEvictionPolicy()
Accessor


isEternal

public boolean isEternal()
Accessor


getTimeToIdleSeconds

public long getTimeToIdleSeconds()
Accessor


getTimeToLiveSeconds

public long getTimeToLiveSeconds()
Accessor


isOverflowToDisk

public boolean isOverflowToDisk()
Accessor


isDiskPersistent

public boolean isDiskPersistent()
Accessor


getDiskExpiryThreadIntervalSeconds

public long getDiskExpiryThreadIntervalSeconds()
Accessor


getCacheEventListenerConfigurations

public java.util.List getCacheEventListenerConfigurations()
Accessor


getCacheExtensionConfigurations

public java.util.List getCacheExtensionConfigurations()
Accessor


getBootstrapCacheLoaderFactoryConfiguration

public CacheConfiguration.BootstrapCacheLoaderFactoryConfiguration getBootstrapCacheLoaderFactoryConfiguration()
Accessor


getCacheExceptionHandlerFactoryConfiguration

public CacheConfiguration.CacheExceptionHandlerFactoryConfiguration getCacheExceptionHandlerFactoryConfiguration()
Accessor


getCacheLoaderFactoryConfiguration

public CacheConfiguration.CacheLoaderFactoryConfiguration getCacheLoaderFactoryConfiguration()
Accessor


ehcache