|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.fulcrum.cache.impl.DefaultGlobalCacheService
public class DefaultGlobalCacheService
This Service functions as a Global Cache. A global cache is a good place to store items that you may need to access often but don't necessarily need (or want) to fetch from the database everytime. A good example would be a look up table of States that you store in a database and use throughout your application. Since information about States doesn't change very often, you could store this information in the Global Cache and decrease the overhead of hitting the database everytime you need State information.
Field Summary | |
---|---|
protected Hashtable |
cache
The cache |
static String |
CACHE_CHECK_FREQUENCY
The property for the Cache check frequency |
static long |
DEFAULT_CACHE_CHECK_FREQUENCY
Cache check frequency in Millis (1000 Millis = 1 second). |
static int |
DEFAULT_INITIAL_CACHE_SIZE
Initial size of hash table Value must be > 0. |
static String |
INITIAL_CACHE_SIZE
The property for the InitalCacheSize |
Fields inherited from interface org.apache.fulcrum.cache.GlobalCacheService |
---|
ROLE |
Constructor Summary | |
---|---|
DefaultGlobalCacheService()
|
Method Summary | |
---|---|
void |
addObject(String id,
CachedObject o)
Adds an object to the cache. |
void |
clearCache()
Iterate through the cache and remove or refresh stale objects. |
void |
configure(org.apache.avalon.framework.configuration.Configuration conf)
Avalon component lifecycle method |
void |
dispose()
Avalon component lifecycle method |
void |
flushCache()
Flush the cache of all objects. |
long |
getCacheCheckFrequency()
Get the Cache Check Frequency in milliseconds |
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. |
protected String |
getName()
Deprecated. part of the pre-avalon compatibility layer |
int |
getNumberOfObjects()
Returns the number of objects currently stored in the cache |
CachedObject |
getObject(String id)
Returns an item from the cache. /** Returns an item from the cache. |
void |
initialize()
Avalon component lifecycle method |
void |
removeObject(String id)
Removes an object from the cache. |
void |
run()
Circle through the cache and remove stale objects. |
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
---|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_INITIAL_CACHE_SIZE
public static final String INITIAL_CACHE_SIZE
public static final String CACHE_CHECK_FREQUENCY
public static final long DEFAULT_CACHE_CHECK_FREQUENCY
protected Hashtable cache
Constructor Detail |
---|
public DefaultGlobalCacheService()
Method Detail |
---|
public long getCacheCheckFrequency()
public CachedObject getObject(String id) throws ObjectExpiredException
getObject
in interface GlobalCacheService
id
- The key of the stored object.
ObjectExpiredException,
- when either the object is not in the cache or it has
expired.
ObjectExpiredException
public void addObject(String id, CachedObject o)
addObject
in interface GlobalCacheService
id
- The key to store the object by.o
- The object to cache.public void removeObject(String id)
removeObject
in interface GlobalCacheService
id
- The String id for the object.public List getKeys()
getKeys
in interface GlobalCacheService
String
's representing the keys to
objects in the cache.public List getCachedObjects()
getCachedObjects
in interface GlobalCacheService
CachedObject
objects held in the cachepublic void run()
run
in interface Runnable
public void clearCache()
public int getNumberOfObjects()
getNumberOfObjects
in interface GlobalCacheService
public int getCacheSize() throws IOException
getCacheSize
in interface GlobalCacheService
IOException
public void flushCache()
flushCache
in interface GlobalCacheService
public void configure(org.apache.avalon.framework.configuration.Configuration conf) throws org.apache.avalon.framework.configuration.ConfigurationException
configure
in interface org.apache.avalon.framework.configuration.Configurable
org.apache.avalon.framework.configuration.ConfigurationException
public void initialize() throws Exception
initialize
in interface org.apache.avalon.framework.activity.Initializable
Exception
public void dispose()
dispose
in interface org.apache.avalon.framework.activity.Disposable
protected String getName()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |