public abstract class GeneratingCache<K,V> extends Cache<K,V>
Cache.ListEntry, Cache.NullIterator
Modifier and Type | Field and Description |
---|---|
private Cache.ListEntry |
curEntry
The entry being generated
|
Constructor and Description |
---|
GeneratingCache(int maxEntries,
int maxTime)
Constructor - sets up the parameters of the cache.
|
Modifier and Type | Method and Description |
---|---|
void |
addDependency(Dependency d)
Can be called by the generate() method to add a dependency to the
key being generated.
|
V |
find(K key)
Check the cache for an entry matching the given key.
|
protected abstract V |
generate(K key)
Called when find() fails to locate an entry for the given key.
|
cleanup, clear, dependenciesValid, getDependencies, has, lastSet, logAction, remove, size
private Cache.ListEntry curEntry
public GeneratingCache(int maxEntries, int maxTime)
maxEntries
- Maximum # of entries. Beyond this, older ones
will be removed. Zero means no limit.maxTime
- Time (in seconds) an entry can stay in the cache
without being used. Entries older than this will
be removed. Zero means no limit.public V find(K key) throws Exception
key
- The key to look upException
public void addDependency(Dependency d)
d
- The dependency to addprotected abstract V generate(K key) throws Exception
key
- The key to generate a value for.Exception
- If a value cannot be generated for any reason.