| java.lang.Object org.springframework.cache.ehcache.EhCacheFactoryBean
EhCacheFactoryBean | public class EhCacheFactoryBean implements FactoryBean,BeanNameAware,InitializingBean(Code) | | 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.3 or higher.
author: Dmitriy Kopylenko author: Juergen Hoeller since: 1.1.1 See Also: EhCacheFactoryBean.setCacheManager See Also: EhCacheManagerFactoryBean See Also: net.sf.ehcache.Cache |
Field Summary | |
final protected Log | logger |
Method Summary | |
public void | afterPropertiesSet() | protected Ehcache | decorateCache(Cache cache) Decorate the given Cache, if necessary. | 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. | public void | setCacheEntryFactory(CacheEntryFactory cacheEntryFactory) Set an EHCache
net.sf.ehcache.constructs.blocking.CacheEntryFactory to use for a self-populating cache. | public void | setCacheManager(CacheManager cacheManager) Set a CacheManager from which to retrieve a named Cache instance. | public void | setCacheName(String cacheName) Set a name for which to retrieve or create a cache instance. | public void | setDiskExpiryThreadIntervalSeconds(int diskExpiryThreadIntervalSeconds) Set the number of seconds between runs of the disk expiry thread. | public void | setDiskPersistent(boolean diskPersistent) Set whether the disk store persists between restarts of the Virtual Machine. | public void | setDiskStorePath(String diskStorePath) Set the location of temporary files for the disk store of this cache. | public void | setEternal(boolean eternal) Set whether elements are considered as eternal. | public void | setMaxElementsInMemory(int maxElementsInMemory) Specify the maximum number of cached objects in memory. | public void | setMemoryStoreEvictionPolicy(MemoryStoreEvictionPolicy memoryStoreEvictionPolicy) Set the memory style eviction policy for this cache. | public void | setOverflowToDisk(boolean overflowToDisk) Set whether elements can overflow to disk when the in-memory cache
has reached the maximum size limit. | 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. | public void | setTimeToLive(int timeToLive) Set t he time in seconds to live for an element before it expires,
i.e. |
logger | final protected Log logger(Code) | | |
afterPropertiesSet | public void afterPropertiesSet() throws CacheException, IOException(Code) | | |
decorateCache | protected Ehcache decorateCache(Cache cache)(Code) | | Decorate the given Cache, if necessary.
The default implementation simply returns the given cache object as-is.
Parameters: cache - the raw Cache object, based on the configuration of this FactoryBean the (potentially decorated) cache object to be registered with the CacheManager |
isSingleton | public boolean isSingleton()(Code) | | |
setCacheEntryFactory | public void setCacheEntryFactory(CacheEntryFactory cacheEntryFactory)(Code) | | Set an EHCache
net.sf.ehcache.constructs.blocking.CacheEntryFactory to use for a self-populating cache. If such a factory is specified,
the cache will be decorated with EHCache's
net.sf.ehcache.constructs.blocking.SelfPopulatingCache .
The specified factory can be of type
net.sf.ehcache.constructs.blocking.UpdatingCacheEntryFactory ,
which will lead to the use of an
net.sf.ehcache.constructs.blocking.UpdatingSelfPopulatingCache .
Note: Any such self-populating cache is automatically a blocking cache.
See Also: net.sf.ehcache.constructs.blocking.SelfPopulatingCache See Also: net.sf.ehcache.constructs.blocking.UpdatingSelfPopulatingCache See Also: net.sf.ehcache.constructs.blocking.UpdatingCacheEntryFactory |
setCacheManager | public void setCacheManager(CacheManager cacheManager)(Code) | | 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.
See Also: EhCacheManagerFactoryBean See Also: net.sf.ehcache.CacheManager.getInstance |
setCacheName | public void setCacheName(String cacheName)(Code) | | Set a name for which to retrieve or create a cache instance.
Default is the bean name of this EhCacheFactoryBean.
|
setDiskExpiryThreadIntervalSeconds | public void setDiskExpiryThreadIntervalSeconds(int diskExpiryThreadIntervalSeconds)(Code) | | Set the number of seconds between runs of the disk expiry thread.
The default is 120 seconds.
|
setDiskPersistent | public void setDiskPersistent(boolean diskPersistent)(Code) | | Set whether the disk store persists between restarts of the Virtual Machine.
The default is "false".
|
setDiskStorePath | public void setDiskStorePath(String diskStorePath)(Code) | | Set the location of temporary files for the disk store of this cache.
Default is the CacheManager's disk store path.
|
setEternal | public void setEternal(boolean eternal)(Code) | | Set whether elements are considered as eternal. If "true", timeouts
are ignored and the element is never expired. Default is "false".
|
setMaxElementsInMemory | public void setMaxElementsInMemory(int maxElementsInMemory)(Code) | | Specify the maximum number of cached objects in memory.
Default is 10000 elements.
|
setMemoryStoreEvictionPolicy | public void setMemoryStoreEvictionPolicy(MemoryStoreEvictionPolicy memoryStoreEvictionPolicy)(Code) | | 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".
|
setOverflowToDisk | public void setOverflowToDisk(boolean overflowToDisk)(Code) | | Set whether elements can overflow to disk when the in-memory cache
has reached the maximum size limit. Default is "true".
|
setTimeToIdle | public void setTimeToIdle(int timeToIdle)(Code) | | 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.
|
setTimeToLive | public void setTimeToLive(int timeToLive)(Code) | | 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.
|
|
|