Package org.apache.fulcrum.cache.impl
Class EHCacheService
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.fulcrum.cache.impl.EHCacheService
- All Implemented Interfaces:
- Runnable,- org.apache.avalon.framework.activity.Disposable,- org.apache.avalon.framework.activity.Initializable,- org.apache.avalon.framework.configuration.Configurable,- org.apache.avalon.framework.logger.LogEnabled,- org.apache.avalon.framework.thread.ThreadSafe,- GlobalCacheService
public class EHCacheService
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements GlobalCacheService, Runnable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.thread.ThreadSafe
Default implementation of EHCacheService (Ehcache 2)
- Author:
- Eric Pugh, Thomas Vandahl
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final longCache check frequency in Millis (1000 Millis = 1 second).Fields inherited from interface org.apache.fulcrum.cache.GlobalCacheServiceROLE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescription<T> voidaddObject(String objectId, CachedObject<T> object) Adds an object to the cache.voidconfigure(org.apache.avalon.framework.configuration.Configuration config) voiddispose()voidFlush the cache of all objects.List<CachedObject<?>> Returns a copy of the non-expired CachedObjects in the cache as a list.intReturns the current size of the cache.getKeys()Returns a copy of keys to objects in the cache as a list.intReturns the number of objects in the cache.<T> CachedObject<T> Gets a cached object given its id (a String).voidvoidremoveObject(String objectId) Removes an object from the cache.voidrun()Circle through the cache and refresh stale objects.Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabledenableLogging, getLogger, setupLogger, setupLogger, setupLogger
- 
Field Details- 
DEFAULT_CACHE_CHECK_FREQUENCYpublic static final long DEFAULT_CACHE_CHECK_FREQUENCYCache check frequency in Millis (1000 Millis = 1 second). Value must be > 0. Default = 5 seconds- See Also:
 
 
- 
- 
Constructor Details- 
EHCacheServicepublic EHCacheService()
 
- 
- 
Method Details- 
configurepublic void configure(org.apache.avalon.framework.configuration.Configuration config) throws org.apache.avalon.framework.configuration.ConfigurationException - Specified by:
- configurein interface- org.apache.avalon.framework.configuration.Configurable
- Throws:
- org.apache.avalon.framework.configuration.ConfigurationException
- See Also:
 
- 
initialize- Specified by:
- initializein interface- org.apache.avalon.framework.activity.Initializable
- Throws:
- Exception
- See Also:
 
- 
disposepublic void dispose()- Specified by:
- disposein interface- org.apache.avalon.framework.activity.Disposable
- See Also:
 
- 
addObjectDescription copied from interface:GlobalCacheServiceAdds an object to the cache.- Specified by:
- addObjectin interface- GlobalCacheService
- Type Parameters:
- T- type of object to add
- Parameters:
- objectId- The String id for the object.
- object- The object to add to the cache.
- See Also:
 
- 
flushCachepublic void flushCache()Description copied from interface:GlobalCacheServiceFlush the cache of all objects.- Specified by:
- flushCachein interface- GlobalCacheService
- See Also:
 
- 
getCachedObjectsDescription copied from interface:GlobalCacheServiceReturns a copy of the non-expired CachedObjects in the cache as a list.- Specified by:
- getCachedObjectsin interface- GlobalCacheService
- Returns:
- A List of CachedObjectobjects held in the cache
- See Also:
 
- 
getCacheSizeDescription copied from interface:GlobalCacheServiceReturns the current size of the cache.- Specified by:
- getCacheSizein interface- GlobalCacheService
- Returns:
- int representing current cache size in number of bytes
- Throws:
- IOException- if unable to return cache size
- See Also:
 
- 
getKeysDescription copied from interface:GlobalCacheServiceReturns a copy of keys to objects in the cache as a list. Note that keys to expired objects are not returned.- Specified by:
- getKeysin interface- GlobalCacheService
- Returns:
- A List of String's representing the keys to objects in the cache.
- See Also:
 
- 
getNumberOfObjectspublic int getNumberOfObjects()Description copied from interface:GlobalCacheServiceReturns the number of objects in the cache.- Specified by:
- getNumberOfObjectsin interface- GlobalCacheService
- Returns:
- int The current number of objects in the cache.
- See Also:
 
- 
getObjectDescription copied from interface:GlobalCacheServiceGets a cached object given its id (a String).- Specified by:
- getObjectin interface- GlobalCacheService
- Type Parameters:
- T- type of object to return
- Parameters:
- objectId- The String id for the object.
- Returns:
- A CachedObject.
- Throws:
- ObjectExpiredException- if the object has expired in the cache.
- See Also:
 
- 
removeObjectDescription copied from interface:GlobalCacheServiceRemoves an object from the cache.- Specified by:
- removeObjectin interface- GlobalCacheService
- Parameters:
- objectId- The String id for the object.
- See Also:
 
- 
runpublic void run()Circle through the cache and refresh stale objects. Frequency is determined by the cacheCheckFrequency property.
 
-