public class TimedCache<K,V>
extends java.lang.Object
TimedCache storyCache = new TimedCache(30, 60000);
public Story getCurrentStory(String id)
{
Story story = (Story) storyCache.get(id);
if (story == null) {
story = DB.queryStoryDatabase(id);
storyCache.put(id, story);
}
return story;
}
Constructor and Description |
---|
TimedCache(int capacity,
long expireInterval)
Creates a new timed LRU cache.
|
Modifier and Type | Method and Description |
---|---|
V |
get(K key)
Gets an item from the cache, returning null if expired.
|
V |
put(K key,
V value)
Put a new item in the cache.
|