org.apache.fulcrum.cache
Interface GlobalCacheService

All Superinterfaces:
org.apache.avalon.framework.component.Component
All Known Implementing Classes:
DefaultGlobalCacheService, EHCacheService, JCSCacheService

public interface GlobalCacheService
extends org.apache.avalon.framework.component.Component

GlobalCacheService interface.

Version:
$Id: GlobalCacheService.java 927153 2010-03-24 18:55:08Z tv $
Author:
Dave Bryson, Peter Courcoux

Field Summary
static String ROLE
          Avalon role - used to id the component within the manager
 
Method Summary
 void addObject(String id, CachedObject o)
          Adds an object to the cache.
 void flushCache()
          Flush the cache of all objects.
 List getCachedObjects()
          Returns a copy of the non-expired CachedObjects in the cache as a list.
 int getCacheSize()
          Returns the current size of the cache.
 List getKeys()
          Returns a copy of keys to objects in the cache as a list.
 int getNumberOfObjects()
          Returns the number of objects in the cache.
 CachedObject getObject(String id)
          Gets a cached object given its id (a String).
 void removeObject(String id)
          Removes an object from the cache.
 

Field Detail

ROLE

static final String ROLE
Avalon role - used to id the component within the manager

Method Detail

getObject

CachedObject getObject(String id)
                       throws ObjectExpiredException
Gets a cached object given its id (a String).

Parameters:
id - The String id for the object.
Returns:
A CachedObject.
Throws:
ObjectExpiredException, - if the object has expired in the cache.
ObjectExpiredException

addObject

void addObject(String id,
               CachedObject o)
Adds an object to the cache.

Parameters:
id - The String id for the object.
o - The object to add to the cache.

removeObject

void removeObject(String id)
Removes an object from the cache.

Parameters:
id - The String id for the object.

getKeys

List 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 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

int getCacheSize()
                 throws IOException
Returns the current size of the cache.

Returns:
int representing current cache size in number of bytes
Throws:
IOException

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.



Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.