|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.nees.util.cache.burst.Cache
A cache, backed by an expensive backing store. Each object has a TTL and fetches result in batch requests against the backing store that pre-fetch a fixed-length batch of objects that are due to expire.
This kind of caching strategy is optimized for bursty access patterns.
Does nothing to control cache size; will grow indefinitely.
| Nested Class Summary | |
static interface |
Cache.BatchStore
Implement this to provide a backing store to a cache. |
protected class |
Cache.Entry
|
protected class |
Cache.ExpirationTimeComparator
|
| Constructor Summary | |
Cache(Cache.BatchStore s)
|
|
| Method Summary | |
void |
clear()
Clears the cache. |
java.lang.Object[] |
fetch(java.lang.Object[] k,
long ttl)
Get objects from the backing store. |
java.lang.Object |
fetch(java.lang.Object k,
long ttl)
Get an object from the backing store |
java.lang.Object |
get(java.lang.Object k,
long ttl)
Get an object from the cache, or from the backing store if it's expired hasn't been fetched before. |
int |
getBatchSize()
Get the number of objects to retrieve each batch, if necessary |
long |
getPrefetchInterval()
Get the prefetch interval |
protected Cache.BatchStore |
getStore()
|
void |
put(java.lang.Object k,
java.lang.Object v,
long ttl)
|
void |
setBatchSize(int bs)
Set the number of objects to retrieve each batch, if necessary |
void |
setPrefetchInterval(long ms)
Set the prefetch interval. |
protected void |
setStore(Cache.BatchStore s)
|
void |
shrink(double factor)
Shrinks the cache by discarding n of the closest-to-expiring objects where n is a given fraction of the cache's total size. |
int |
size()
Get the size of the cache. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Cache(Cache.BatchStore s)
| Method Detail |
public int size()
public void setBatchSize(int bs)
bs - the batch sizepublic int getBatchSize()
public void setPrefetchInterval(long ms)
ms - the prefetch interval in mspublic long getPrefetchInterval()
protected void setStore(Cache.BatchStore s)
protected Cache.BatchStore getStore()
public void put(java.lang.Object k,
java.lang.Object v,
long ttl)
ttl - time-to-live in ms
public java.lang.Object get(java.lang.Object k,
long ttl)
k - the keyttl - the ttl, if the object has never been fetched before
public java.lang.Object[] fetch(java.lang.Object[] k,
long ttl)
k - the keysttl - the time-to-live for the objects.
public java.lang.Object fetch(java.lang.Object k,
long ttl)
public void clear()
public void shrink(double factor)
factor - the proportion of the total size to discard.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||