|
|||||||||
| Home >> All >> org >> apache >> turbine >> services >> [ cache overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.turbine.services.cache
Class TurbineGlobalCacheService

java.lang.Objectorg.apache.turbine.services.BaseInitable
org.apache.turbine.services.BaseService
org.apache.turbine.services.TurbineBaseService
org.apache.turbine.services.cache.TurbineGlobalCacheService
- All Implemented Interfaces:
- GlobalCacheService, org.apache.turbine.services.Initable, java.lang.Runnable, org.apache.turbine.services.Service
- public class TurbineGlobalCacheService
- extends org.apache.turbine.services.TurbineBaseService
- implements GlobalCacheService, java.lang.Runnable
- extends org.apache.turbine.services.TurbineBaseService
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
- classname
- the classname of this service
- cache.initial.size
- Initial size of hash table use to store cached objects. If this property is not present, the default value is 20
- cache.check.frequency
- Cache check frequency in Millis (1000 Millis = 1 second). If this property is not present, the default value is 5000
- Version:
- $Id: TurbineGlobalCacheService.java 264148 2005-08-29 14:21:04Z henning $
| Field Summary | |
private java.util.Hashtable |
cache
The cache. |
static java.lang.String |
CACHE_CHECK_FREQUENCY
The property for the Cache check frequency |
private long |
cacheCheckFrequency
cacheCheckFrequency (default - 5 seconds) |
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 |
DEFAULT_INITIAL_CACHE_SIZE
public static final int DEFAULT_INITIAL_CACHE_SIZE
- Initial size of hash table
Value must be > 0.
Default = 20
- See Also:
- Constant Field Values
INITIAL_CACHE_SIZE
public static final java.lang.String INITIAL_CACHE_SIZE
- The property for the InitalCacheSize
- See Also:
- Constant Field Values
CACHE_CHECK_FREQUENCY
public static final java.lang.String CACHE_CHECK_FREQUENCY
- The property for the Cache check frequency
- See Also:
- Constant Field Values
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
cache
private java.util.Hashtable cache
- The cache.
cacheCheckFrequency
private long cacheCheckFrequency
- cacheCheckFrequency (default - 5 seconds)
| Constructor Detail |
TurbineGlobalCacheService
public TurbineGlobalCacheService()
- Constructor.
| Method Detail |
init
public void init()
throws org.apache.turbine.services.InitializationException
- Called the first time the Service is used.
- Specified by:
initin interfaceorg.apache.turbine.services.Initable
getObject
public CachedObject getObject(java.lang.String id) throws ObjectExpiredException
- Returns an item from the cache. RefreshableCachedObject will be
refreshed if it is expired and not untouched.
- Specified by:
getObjectin interfaceGlobalCacheService
addObject
public void addObject(java.lang.String id, CachedObject o)
- Adds an object to the cache.
- Specified by:
addObjectin interfaceGlobalCacheService
removeObject
public void removeObject(java.lang.String id)
- Removes an object from the cache.
- Specified by:
removeObjectin interfaceGlobalCacheService
run
public void run()
- Circle through the cache and remove stale objects. Frequency
is determined by the cacheCheckFrequency property.
- Specified by:
runin interfacejava.lang.Runnable
clearCache
public void clearCache()
- Iterate through the cache and remove or refresh stale objects.
getNumberOfObjects
public int getNumberOfObjects()
- Returns the number of objects currently stored in the cache
- Specified by:
getNumberOfObjectsin interfaceGlobalCacheService
getCacheSize
public int getCacheSize()
throws java.io.IOException
- Returns the current size of the cache.
- Specified by:
getCacheSizein interfaceGlobalCacheService
flushCache
public void flushCache()
- Flush the cache of all objects.
- Specified by:
flushCachein interfaceGlobalCacheService
|
|||||||||
| Home >> All >> org >> apache >> turbine >> services >> [ cache overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC