|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.turbine.services.BaseInitable org.apache.turbine.services.BaseService org.apache.turbine.services.TurbineBaseService org.apache.turbine.services.cache.TurbineGlobalCacheService
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.
The following properties are needed to configure this service:
services.GlobalCacheService.classname=org.apache.turbine.services.cache.TurbineGlobalCacheService
services.GlobalCacheService.cache.initial.size=20
services.GlobalCacheService.cache.check.frequency=5000
Field Summary | |
static java.lang.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 java.lang.String |
INITIAL_CACHE_SIZE
The property for the InitalCacheSize |
Fields inherited from class org.apache.turbine.services.BaseService |
configuration, name, serviceBroker |
Fields inherited from class org.apache.turbine.services.BaseInitable |
initableBroker, isInitialized |
Fields inherited from interface org.apache.turbine.services.cache.GlobalCacheService |
SERVICE_NAME |
Constructor Summary | |
TurbineGlobalCacheService()
Constructor. |
Method Summary | |
void |
addObject(java.lang.String id,
CachedObject o)
Adds an object to the cache. |
void |
clearCache()
Iterate through the cache and remove or refresh stale objects. |
void |
flushCache()
Flush the cache of all objects. |
int |
getCacheSize()
Returns the current size of the cache. |
int |
getNumberOfObjects()
Returns the number of objects currently stored in the cache |
CachedObject |
getObject(java.lang.String id)
Returns an item from the cache. |
void |
init()
Called the first time the Service is used. |
void |
removeObject(java.lang.String id)
Removes an object from the cache. |
void |
run()
Circle through the cache and remove stale objects. |
Methods inherited from class org.apache.turbine.services.TurbineBaseService |
init, init, init, shutdown |
Methods inherited from class org.apache.turbine.services.BaseService |
getConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBroker |
Methods inherited from class org.apache.turbine.services.BaseInitable |
getInit, getInitableBroker, setInit, setInitableBroker |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.turbine.services.Service |
getConfiguration, getName, getProperties, setName, setServiceBroker |
Methods inherited from interface org.apache.turbine.services.Initable |
getInit, init, setInitableBroker, shutdown |
Field Detail |
public static final int DEFAULT_INITIAL_CACHE_SIZE
public static final java.lang.String INITIAL_CACHE_SIZE
public static final java.lang.String CACHE_CHECK_FREQUENCY
public static final long DEFAULT_CACHE_CHECK_FREQUENCY
Constructor Detail |
public TurbineGlobalCacheService()
Method Detail |
public void init() throws InitializationException
init
in interface Initable
init
in class TurbineBaseService
InitializationException
public CachedObject getObject(java.lang.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.public void addObject(java.lang.String id, CachedObject o)
addObject
in interface GlobalCacheService
id
- The key to store the object by.o
- The object to cache.public void removeObject(java.lang.String id)
removeObject
in interface GlobalCacheService
id
- The String id for the object.public void run()
run
in interface java.lang.Runnable
public void clearCache()
public int getNumberOfObjects()
getNumberOfObjects
in interface GlobalCacheService
public int getCacheSize() throws java.io.IOException
getCacheSize
in interface GlobalCacheService
java.io.IOException
public void flushCache()
flushCache
in interface GlobalCacheService
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |