|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.turbine.services.cache.CachedObject
org.apache.turbine.services.cache.RefreshableCachedObject
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.
Field Summary |
Fields inherited from class org.apache.turbine.services.cache.CachedObject |
created, DEFAULT, FOREVER |
Constructor Summary | |
RefreshableCachedObject(Refreshable o)
Constructor; sets the object to expire in the default time (30 minutes). |
|
RefreshableCachedObject(Refreshable o,
long expires)
Constructor. |
Method Summary | |
long |
getTTL()
Gets the timeToLive value. |
boolean |
isUntouched()
Returns true if the object hasn't been touched in the previous TTL period. |
void |
refresh()
Refresh the object and the created time. |
void |
setTTL(long timeToLive)
Sets the timeToLive value |
void |
touch()
Sets the last acccess time to the current time. |
Methods inherited from class org.apache.turbine.services.cache.CachedObject |
getContents, getCreated, getExpires, getStale, isStale, setExpires, setStale |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public RefreshableCachedObject(Refreshable o)
o
- The object you want to cache.public RefreshableCachedObject(Refreshable o, long expires)
o
- The object to cache.expires
- How long before the object expires, in ms,
e.g. 1000 = 1 second.Method Detail |
public void setTTL(long timeToLive)
timeToLive
- the new Value in millisecondspublic long getTTL()
public void touch()
public boolean isUntouched()
public void refresh()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |