Package org.apache.fulcrum.cache
Interface GlobalCacheService
- All Known Implementing Classes:
DefaultGlobalCacheService
,EHCacheService
,JCSCacheService
public interface GlobalCacheService
GlobalCacheService interface.
- Version:
- $Id$
- Author:
- Dave Bryson, Peter CourefreshableCachedObjectux
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescription<T> void
addObject
(String objectId, CachedObject<T> object) Adds an object to the cache.void
Flush the cache of all objects.List
<CachedObject<?>> Returns a copy of the non-expired CachedObjects in the cache as a list.int
Returns the current size of the cache.getKeys()
Returns a copy of keys to objects in the cache as a list.int
Returns the number of objects in the cache.<T> CachedObject
<T> Gets a cached object given its id (a String).void
removeObject
(String objectId) Removes an object from the cache.
-
Field Details
-
ROLE
Avalon role - used to id the component within the manager
-
-
Method Details
-
getObject
Gets a cached object given its id (a String).- 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.
-
addObject
Adds an object to the cache.- Type Parameters:
T
- type of object to add- Parameters:
objectId
- The String id for the object.object
- The object to add to the cache.
-
removeObject
Removes an object from the cache.- Parameters:
objectId
- The String id for the object.
-
getKeys
Returns a copy of keys to objects in the cache as a list. Note that keys to expired objects are not returned.- Returns:
- A List of
String
's representing the keys to objects in the cache.
-
getCachedObjects
List<CachedObject<?>> getCachedObjects()Returns a copy of the non-expired CachedObjects in the cache as a list.- Returns:
- A List of
CachedObject
objects held in the cache
-
getCacheSize
Returns the current size of the cache.- Returns:
- int representing current cache size in number of bytes
- Throws:
IOException
- if unable to return cache size
-
getNumberOfObjects
int getNumberOfObjects()Returns the number of objects in the cache.- Returns:
- int The current number of objects in the cache.
-
flushCache
void flushCache()Flush the cache of all objects.
-