| java.lang.Object org.apache.turbine.services.cache.CachedObject org.apache.turbine.services.cache.RefreshableCachedObject
RefreshableCachedObject | public class RefreshableCachedObject extends CachedObject (Code) | | 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.
author: Nissim Karpenstein author: Henning P. Schmiedehausen version: $Id: RefreshableCachedObject.java 534527 2007-05-02 16:10:59Z tv $ |
Method Summary | |
public synchronized long | getTTL() Gets the timeToLive value. | public synchronized boolean | isUntouched() Returns true if the object hasn't been touched
in the previous TTL period. | public void | refresh() Refresh the object and the created time. | public synchronized void | setTTL(long timeToLive) | public synchronized void | touch() Sets the last acccess time to the current time. |
RefreshableCachedObject | public RefreshableCachedObject(Refreshable o)(Code) | | Constructor; sets the object to expire in the default time (30
minutes).
Parameters: o - The object you want to cache. |
RefreshableCachedObject | public RefreshableCachedObject(Refreshable o, long expires)(Code) | | Constructor.
Parameters: o - The object to cache. Parameters: expires - How long before the object expires, in ms,e.g. 1000 = 1 second. |
getTTL | public synchronized long getTTL()(Code) | | Gets the timeToLive value.
The current timeToLive value (in milliseconds) |
isUntouched | public synchronized boolean isUntouched()(Code) | | Returns true if the object hasn't been touched
in the previous TTL period.
|
refresh | public void refresh()(Code) | | Refresh the object and the created time.
|
setTTL | public synchronized void setTTL(long timeToLive)(Code) | | Sets the timeToLive value
Parameters: timeToLive - the new Value in milliseconds |
touch | public synchronized void touch()(Code) | | Sets the last acccess time to the current time.
|
|
|