public class SimpleCache<K,V> extends Cache<K,V>
Cache.ListEntry, Cache.NullIterator
Constructor and Description |
---|
SimpleCache(int maxEntries,
int maxTime)
Constructor - sets up the parameters of the cache.
|
Modifier and Type | Method and Description |
---|---|
void |
addDependency(K key,
Dependency d)
Add a dependency to an existing entry.
|
V |
get(K key)
Gets the value associated with a key, or null if none.
|
void |
set(K key,
V value)
Set the value for a key.
|
void |
set(K key,
V value,
Dependency dependency)
Set the value for a key, optionally adding a dependency for it.
|
cleanup, clear, dependenciesValid, getDependencies, has, lastSet, logAction, remove, size
public SimpleCache(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 void set(K key, V value)
key
- Key to set the value forvalue
- Value for that key.public void set(K key, V value, Dependency dependency)
key
- The key that will be used to look up the valuevalue
- The value to associate with that keydependency
- A dependency to add to the key, or null for none.public V get(K key)
key
- The key to look forpublic void addDependency(K key, Dependency d)
key
- The key to add a dependency tod
- The dependency to add to it.