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 Summary
Fields Modifier and Type Field Description static longDEFAULT_CACHE_CHECK_FREQUENCYCache check frequency in Millis (1000 Millis = 1 second).-
Fields inherited from interface org.apache.fulcrum.cache.GlobalCacheService
ROLE
-
-
Constructor Summary
Constructors Constructor Description EHCacheService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> voidaddObject(String objectId, CachedObject<T> object)Adds an object to the cache.voidconfigure(org.apache.avalon.framework.configuration.Configuration config)voiddispose()voidflushCache()Flush the cache of all objects.List<CachedObject<?>>getCachedObjects()Returns a copy of the non-expired CachedObjects in the cache as a list.intgetCacheSize()Returns the current size of the cache.List<String>getKeys()Returns a copy of keys to objects in the cache as a list.intgetNumberOfObjects()Returns the number of objects in the cache.<T> CachedObject<T>getObject(String objectId)Gets a cached object given its id (a String).voidinitialize()voidremoveObject(String objectId)Removes an object from the cache.voidrun()Circle through the cache and refresh stale objects.
-
-
-
Field Detail
-
DEFAULT_CACHE_CHECK_FREQUENCY
public static final long DEFAULT_CACHE_CHECK_FREQUENCY
Cache check frequency in Millis (1000 Millis = 1 second). Value must be > 0. Default = 5 seconds- See Also:
- Constant Field Values
-
-
Method Detail
-
configure
public void configure(org.apache.avalon.framework.configuration.Configuration config) throws org.apache.avalon.framework.configuration.ConfigurationException- Specified by:
configurein interfaceorg.apache.avalon.framework.configuration.Configurable- Throws:
org.apache.avalon.framework.configuration.ConfigurationException- See Also:
Configurable.configure(org.apache.avalon.framework.configuration.Configuration)
-
initialize
public void initialize() throws Exception- Specified by:
initializein interfaceorg.apache.avalon.framework.activity.Initializable- Throws:
Exception- See Also:
Initializable.initialize()
-
dispose
public void dispose()
- Specified by:
disposein interfaceorg.apache.avalon.framework.activity.Disposable- See Also:
Disposable.dispose()
-
addObject
public <T> void addObject(String objectId, CachedObject<T> object)
Description copied from interface:GlobalCacheServiceAdds an object to the cache.- Specified by:
addObjectin interfaceGlobalCacheService- 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:
GlobalCacheService.addObject(java.lang.String, org.apache.fulcrum.cache.CachedObject)
-
flushCache
public void flushCache()
Description copied from interface:GlobalCacheServiceFlush the cache of all objects.- Specified by:
flushCachein interfaceGlobalCacheService- See Also:
GlobalCacheService.flushCache()
-
getCachedObjects
public List<CachedObject<?>> getCachedObjects()
Description copied from interface:GlobalCacheServiceReturns a copy of the non-expired CachedObjects in the cache as a list.- Specified by:
getCachedObjectsin interfaceGlobalCacheService- Returns:
- A List of
CachedObjectobjects held in the cache - See Also:
GlobalCacheService.getCachedObjects()
-
getCacheSize
public int getCacheSize() throws IOExceptionDescription copied from interface:GlobalCacheServiceReturns the current size of the cache.- Specified by:
getCacheSizein interfaceGlobalCacheService- Returns:
- int representing current cache size in number of bytes
- Throws:
IOException- if unable to return cache size- See Also:
GlobalCacheService.getCacheSize()
-
getKeys
public List<String> getKeys()
Description 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 interfaceGlobalCacheService- Returns:
- A List of
String's representing the keys to objects in the cache. - See Also:
GlobalCacheService.getKeys()
-
getNumberOfObjects
public int getNumberOfObjects()
Description copied from interface:GlobalCacheServiceReturns the number of objects in the cache.- Specified by:
getNumberOfObjectsin interfaceGlobalCacheService- Returns:
- int The current number of objects in the cache.
- See Also:
GlobalCacheService.getNumberOfObjects()
-
getObject
public <T> CachedObject<T> getObject(String objectId) throws ObjectExpiredException
Description copied from interface:GlobalCacheServiceGets a cached object given its id (a String).- Specified by:
getObjectin interfaceGlobalCacheService- 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:
GlobalCacheService.getObject(java.lang.String)
-
removeObject
public void removeObject(String objectId)
Description copied from interface:GlobalCacheServiceRemoves an object from the cache.- Specified by:
removeObjectin interfaceGlobalCacheService- Parameters:
objectId- The String id for the object.- See Also:
GlobalCacheService.removeObject(java.lang.String)
-
-