Package org.apache.fulcrum.cache
Class RefreshableCachedObject<T extends Refreshable>
java.lang.Object
org.apache.fulcrum.cache.CachedObject<T>
org.apache.fulcrum.cache.RefreshableCachedObject<T>
- All Implemented Interfaces:
- Serializable
The idea of the RefreshableCachedObject is that, rather than removing items
 from the cache when they become stale, we'll tell them to refresh themselves
 instead. That way they'll always be in the cache, and the code to refresh
 them will be run by the background thread rather than by a user request
 thread. You can also set a TTL (Time To Live) for the object. This way, if
 the object hasn't been touched for the TTL period, then it will be removed
 from the cache.
 This extends CachedObject and provides a method for refreshing the cached
 object, and resetting its expire time.
- Version:
- $Id$
- Author:
- Nissim Karpenstein, Henning P. Schmiedehausen
- See Also:
- 
Field SummaryFields inherited from class org.apache.fulcrum.cache.CachedObjectcreated, DEFAULT, FOREVER
- 
Constructor SummaryConstructorsConstructorDescriptionRefreshableCachedObject(T object) Constructor; sets the object to expire in the default time (30 minutes).RefreshableCachedObject(T object, long expires) Constructor.
- 
Method SummaryModifier and TypeMethodDescriptionlonglonggetTTL()Gets the timeToLive value.booleanReturns true if the object hasn't been touched in the previous TTL period.voidrefresh()Refresh the object and the created time.voidsetLastAccess(long lastAccess) voidsetTTL(long timeToLive) Sets the timeToLive valuevoidtouch()Sets the last access time to the current time.Methods inherited from class org.apache.fulcrum.cache.CachedObjectgetContents, getCreated, getExpires, isStale, setExpires, setStale
- 
Constructor Details- 
RefreshableCachedObjectConstructor; sets the object to expire in the default time (30 minutes).- Parameters:
- object- The object you want to cache.
 
- 
RefreshableCachedObjectConstructor.- Parameters:
- object- The object to cache.
- expires- How long before the object expires, in ms, e.g. 1000 = 1 second.
 
 
- 
- 
Method Details- 
setTTLpublic void setTTL(long timeToLive) Sets the timeToLive value- Parameters:
- timeToLive- the new Value in milliseconds
 
- 
getTTLpublic long getTTL()Gets the timeToLive value.- Returns:
- The current timeToLive value (in milliseconds)
 
- 
touchpublic void touch()Sets the last access time to the current time.
- 
isUntouchedpublic boolean isUntouched()Returns true if the object hasn't been touched in the previous TTL period.- Returns:
- boolean status of object
 
- 
refreshpublic void refresh()Refresh the object and the created time.
- 
getLastAccesspublic long getLastAccess()
- 
setLastAccesspublic void setLastAccess(long lastAccess) 
 
-