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;
}
|