Save This Page
Home » spring-framework-2.5.5-with-dependencies » org.springframework.cache » ehcache » [javadoc | source]
org.springframework.cache.ehcache
public class: EhCacheFactoryBean [javadoc | source]
java.lang.Object
   org.springframework.cache.ehcache.EhCacheFactoryBean

All Implemented Interfaces:
    BeanNameAware, InitializingBean, FactoryBean

FactoryBean that creates a named EHCache net.sf.ehcache.Cache instance (or a decorator that implements the net.sf.ehcache.Ehcache interface), representing a cache region within an EHCache net.sf.ehcache.CacheManager .

If the specified named cache is not configured in the cache configuration descriptor, this FactoryBean will construct an instance of a Cache with the provided name and the specified cache properties and add it to the CacheManager for later retrieval. If some or all properties are not set at configuration time, this FactoryBean will use defaults.

Note: If the named Cache instance is found, the properties will be ignored and the Cache instance will be retrieved from the CacheManager.

Note: As of Spring 2.0, this FactoryBean is based on EHCache 1.2's API (in particular the Ehcache interface and the extended Cache constructor). It is not compatible with EHCache 1.1 anymore; please upgrade to EHCache 1.2.4 or higher.

Field Summary
protected final  Log logger     
Method from org.springframework.cache.ehcache.EhCacheFactoryBean Summary:
afterPropertiesSet,   decorateCache,   getObject,   getObjectType,   isSingleton,   setBeanName,   setBlocking,   setCacheEntryFactory,   setCacheManager,   setCacheName,   setDiskExpiryThreadIntervalSeconds,   setDiskPersistent,   setDiskStorePath,   setEternal,   setMaxElementsInMemory,   setMaxElementsOnDisk,   setMemoryStoreEvictionPolicy,   setOverflowToDisk,   setTimeToIdle,   setTimeToLive
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.cache.ehcache.EhCacheFactoryBean Detail:
 public  void afterPropertiesSet() throws IOException, CacheException 
 protected Ehcache decorateCache(Cache cache) 
    Decorate the given Cache, if necessary.

    The default implementation simply returns the given cache object as-is.

 public Object getObject() 
 public Class getObjectType() 
 public boolean isSingleton() 
 public  void setBeanName(String name) 
 public  void setBlocking(boolean blocking) 
    Set whether to use a blocking cache that lets read attempts block until the requested element is created.

    If you intend to build a self-populating blocking cache, consider specifying a CacheEntryFactory .

 public  void setCacheEntryFactory(CacheEntryFactory cacheEntryFactory) 
 public  void setCacheManager(CacheManager cacheManager) 
    Set a CacheManager from which to retrieve a named Cache instance. By default, CacheManager.getInstance() will be called.

    Note that in particular for persistent caches, it is advisable to properly handle the shutdown of the CacheManager: Set up a separate EhCacheManagerFactoryBean and pass a reference to this bean property.

    A separate EhCacheManagerFactoryBean is also necessary for loading EHCache configuration from a non-default config location.

 public  void setCacheName(String cacheName) 
    Set a name for which to retrieve or create a cache instance. Default is the bean name of this EhCacheFactoryBean.
 public  void setDiskExpiryThreadIntervalSeconds(int diskExpiryThreadIntervalSeconds) 
    Set the number of seconds between runs of the disk expiry thread. The default is 120 seconds.
 public  void setDiskPersistent(boolean diskPersistent) 
    Set whether the disk store persists between restarts of the Virtual Machine. The default is "false".
 public  void setDiskStorePath(String diskStorePath) 
    Set the location of temporary files for the disk store of this cache. Default is the CacheManager's disk store path.
 public  void setEternal(boolean eternal) 
    Set whether elements are considered as eternal. If "true", timeouts are ignored and the element is never expired. Default is "false".
 public  void setMaxElementsInMemory(int maxElementsInMemory) 
    Specify the maximum number of cached objects in memory. Default is 10000 elements.
 public  void setMaxElementsOnDisk(int maxElementsOnDisk) 
    Specify the maximum number of cached objects on disk. Default is 10000000 elements.
 public  void setMemoryStoreEvictionPolicy(MemoryStoreEvictionPolicy memoryStoreEvictionPolicy) 
    Set the memory style eviction policy for this cache. Supported values are "LRU", "LFU" and "FIFO", according to the constants defined in EHCache's MemoryStoreEvictionPolicy class. Default is "LRU".
 public  void setOverflowToDisk(boolean overflowToDisk) 
    Set whether elements can overflow to disk when the in-memory cache has reached the maximum size limit. Default is "true".
 public  void setTimeToIdle(int timeToIdle) 
    Set the time in seconds to idle for an element before it expires, that is, the maximum amount of time between accesses before an element expires. This is only used if the element is not eternal. Default is 120 seconds.
 public  void setTimeToLive(int timeToLive) 
    Set t he time in seconds to live for an element before it expires, i.e. the maximum time between creation time and when an element expires. It is only used if the element is not eternal. Default is 120 seconds.