com.caucho.util
Class TimedItem
java.lang.Object
|
+--com.caucho.util.TimedItem
- public class TimedItem
- extends java.lang.Object
A single item timed cache. The item will remain valid until it expires.
TimedItem can simplify database caching.
TimedItem currentStories = new TimedItem(60000);
public ArrayList getCurrentStories()
{
ArrayList storyList = (ArrayList) currentStories.get();
if (storyList == null) {
storyList = DB.queryStoryDatabase();
currentStories.put(storyList);
}
return storyList;
}
Constructor Summary |
TimedItem(long expireInterval)
Create a new timed item with a specified update time |
Method Summary |
java.lang.Object |
get()
Gets the cached value, returning null if expires. |
long |
getExpireInterval()
Returns the expire time for this TimedItem. |
void |
put(java.lang.Object value)
Sets the value. |
void |
setExpireInterval(long expireInterval)
Sets the expire time for this timedItem. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TimedItem
public TimedItem(long expireInterval)
- Create a new timed item with a specified update time
- Parameters:
expireInterval
- the time in milliseconds the item remains valid.
getExpireInterval
public long getExpireInterval()
- Returns the expire time for this TimedItem.
setExpireInterval
public void setExpireInterval(long expireInterval)
- Sets the expire time for this timedItem.
put
public void put(java.lang.Object value)
- Sets the value.
get
public java.lang.Object get()
- Gets the cached value, returning null if expires.