|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.shindig.common.cache.SoftExpiringCache<K,V>
public class SoftExpiringCache<K,V>
A cache that uses a soft expiration policy. Entries will be kept around for potentially as long as the underlying cache permits, but we keep a timestamp around to retain a notion of the actual age. This provides users of this class with the option of keeping an "expired" entry beyond the normal lifetime. As soon as an entry expires from the underlying cache, it disappears from here as well. Note that this isn't actually a cache itself, but rather a wrapper for one. It differs in the getElement method substantially, since the returned objects are not the same as the V parameter.
| Nested Class Summary | |
|---|---|
static class |
SoftExpiringCache.CachedObject<V>
|
| Constructor Summary | |
|---|---|
SoftExpiringCache(Cache<K,V> cache)
Create a new TtlCache with the given capacity and TTL values. |
|
| Method Summary | |
|---|---|
void |
addElement(K key,
V value,
long maxAge)
Add an element to the cache, with the intended max age for its cache entry provided in milliseconds. |
SoftExpiringCache.CachedObject<V> |
getElement(K key)
Retrieve an element from the cache by key. |
void |
setTimeSource(TimeSource timeSource)
Set a new time source. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SoftExpiringCache(Cache<K,V> cache)
cache - The underlying cache that will store actual data.| Method Detail |
|---|
public SoftExpiringCache.CachedObject<V> getElement(K key)
key - Key whose element to look up.
public void addElement(K key,
V value,
long maxAge)
key - The key to store the entry for.value - The value to store.maxAge - The maximum age for this entry before it is deemed expired.public void setTimeSource(TimeSource timeSource)
timeSource - New time source to use.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||