|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.caucho.util.TimedCache<K,V>
public class TimedCache<K,V>
A timed LRU cache. Items remain valid until they expire. TimedCache can simplify database caching.
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 Summary | |
---|---|
TimedCache(int capacity,
long expireInterval)
Creates a new timed LRU cache. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TimedCache(int capacity, long expireInterval)
capacity
- the maximum size of the LRU cacheexpireInterval
- the time an entry remains validMethod Detail |
---|
public V put(K key, V value)
public V get(K key)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |