|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.onebusaway.container.spring.ehcache.EhCacheFactoryBean
public class EhCacheFactoryBean
A Spring FactoryBean
for programmatically creating an EhCache
Cache
with standard configuration options, but also progrmattic
Terracotta configuration.
A special note about Terracotta config. While you can create all your
Terracotta-enabled caches programatically using this FactoryBean, you need to
have at least one Terracotta-enabled cache created the old fashioned way
(through an ehcache.xml
resource config) so that the
CacheManager
will properly enable Terracotta support.
Field Summary | |
---|---|
protected org.apache.commons.logging.Log |
logger
|
Constructor Summary | |
---|---|
EhCacheFactoryBean()
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
|
protected net.sf.ehcache.Ehcache |
decorateCache(net.sf.ehcache.Ehcache cache)
Decorate the given Cache, if necessary. |
net.sf.ehcache.Ehcache |
getObject()
|
Class<?> |
getObjectType()
|
boolean |
isSingleton()
|
void |
setBeanName(String name)
|
void |
setBlocking(boolean blocking)
Set whether to use a blocking cache that lets read attempts block until the requested element is created. |
void |
setCacheEntryFactory(net.sf.ehcache.constructs.blocking.CacheEntryFactory cacheEntryFactory)
Set an EHCache CacheEntryFactory
to use for a self-populating cache. |
void |
setCacheManager(net.sf.ehcache.CacheManager cacheManager)
Set a CacheManager from which to retrieve a named Cache instance. |
void |
setCacheName(String cacheName)
Set a name for which to retrieve or create a cache instance. |
void |
setDiskExpiryThreadIntervalSeconds(int diskExpiryThreadIntervalSeconds)
Set the number of seconds between runs of the disk expiry thread. |
void |
setDiskPersistent(boolean diskPersistent)
Set whether the disk store persists between restarts of the Virtual Machine. |
void |
setEternal(boolean eternal)
Set whether elements are considered as eternal. |
void |
setMaxElementsInMemory(int maxElementsInMemory)
Specify the maximum number of cached objects in memory. |
void |
setMaxElementsOnDisk(int maxElementsOnDisk)
Specify the maximum number of cached objects on disk. |
void |
setMemoryStoreEvictionPolicy(net.sf.ehcache.store.MemoryStoreEvictionPolicy memoryStoreEvictionPolicy)
Set the memory style eviction policy for this cache. |
void |
setOverflowToDisk(boolean overflowToDisk)
Set whether elements can overflow to disk when the in-memory cache has reached the maximum size limit. |
void |
setTerracottaClustered(boolean terracottaClustered)
|
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. |
void |
setTimeToLive(int timeToLive)
Set t he time in seconds to live for an element before it expires, i.e. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final org.apache.commons.logging.Log logger
Constructor Detail |
---|
public EhCacheFactoryBean()
Method Detail |
---|
public void setCacheManager(net.sf.ehcache.CacheManager cacheManager)
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.
EhCacheManagerFactoryBean
,
CacheManager.getInstance()
public void setCacheName(String cacheName)
public void setMaxElementsInMemory(int maxElementsInMemory)
public void setMaxElementsOnDisk(int maxElementsOnDisk)
public void setMemoryStoreEvictionPolicy(net.sf.ehcache.store.MemoryStoreEvictionPolicy memoryStoreEvictionPolicy)
public void setOverflowToDisk(boolean overflowToDisk)
public void setEternal(boolean eternal)
public void setTimeToLive(int timeToLive)
public void setTimeToIdle(int timeToIdle)
public void setDiskPersistent(boolean diskPersistent)
public void setDiskExpiryThreadIntervalSeconds(int diskExpiryThreadIntervalSeconds)
public void setBlocking(boolean blocking)
If you intend to build a self-populating blocking cache, consider
specifying a CacheEntryFactory
.
BlockingCache
,
setCacheEntryFactory(net.sf.ehcache.constructs.blocking.CacheEntryFactory)
public void setTerracottaClustered(boolean terracottaClustered)
public void setCacheEntryFactory(net.sf.ehcache.constructs.blocking.CacheEntryFactory cacheEntryFactory)
CacheEntryFactory
to use for a self-populating cache. If such a factory is specified, the
cache will be decorated with EHCache's
SelfPopulatingCache
.
The specified factory can be of type
UpdatingCacheEntryFactory
, which
will lead to the use of an
UpdatingSelfPopulatingCache
.
Note: Any such self-populating cache is automatically a blocking cache.
SelfPopulatingCache
,
UpdatingSelfPopulatingCache
,
UpdatingCacheEntryFactory
public void setBeanName(String name)
setBeanName
in interface org.springframework.beans.factory.BeanNameAware
public void afterPropertiesSet() throws net.sf.ehcache.CacheException, IOException
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
net.sf.ehcache.CacheException
IOException
protected net.sf.ehcache.Ehcache decorateCache(net.sf.ehcache.Ehcache cache)
cache
- the raw Cache object, based on the configuration of this
FactoryBean
public net.sf.ehcache.Ehcache getObject()
getObject
in interface org.springframework.beans.factory.FactoryBean<net.sf.ehcache.Ehcache>
public Class<?> getObjectType()
getObjectType
in interface org.springframework.beans.factory.FactoryBean<net.sf.ehcache.Ehcache>
public boolean isSingleton()
isSingleton
in interface org.springframework.beans.factory.FactoryBean<net.sf.ehcache.Ehcache>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |