| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULTSIZE |
| Constructor and Description |
|---|
HashedCache()
Create a hashed cache of the default size, 42.
|
HashedCache(int size)
Create a hashed cache of the desired size.
|
| Modifier and Type | Method and Description |
|---|---|
V |
cachedValueFor(K index)
Get the object associated with the given index, keeping the returned item in cache subject to capacity and other settings.
|
void |
clear()
Clears all items from the cache, so that they must be reloaded.
|
int |
compareTo(java.lang.Object nother) |
void |
finalize(V flushCandidate)
Optional override for subclasses - called before flushing an object.
|
void |
flush()
Flushes the cache, removing values until the capacity is reached.
|
int |
getByteSize()
Gets an estimate of the size of the cached values, in bytes.
|
int |
getCapacity()
Gets the maximum number of cached values.
|
java.lang.String |
getName() |
boolean |
getUsingSeparateReaperThread()
If true, creates a separate thread which reaps old entries from the
cache.
|
boolean |
isFlushable(V flushCandidate)
Optional override for subclasses - tests if an object can be flushed.
|
boolean |
isManualFlushing() |
java.util.List<V> |
listCachedValues()
Lists the values currently in cache.
|
boolean |
remove(java.lang.Object index) |
void |
setCapacity(int newSize)
Sets the maximum number of cached values.
|
void |
setManualFlushing(boolean manualFlushing)
Setting this to true turns of automatic flushing done whenever
new cached values are gotten.
|
void |
setUsingSeparateReaperThread(boolean tizit) |
int |
size()
Returns the current cache size (number of cached values).
|
abstract V |
uncachedValueFor(K index)
Get the object associated with the given index, without regard to the cache.
|
public static final int DEFAULTSIZE
public HashedCache()
public HashedCache(int size)
public V cachedValueFor(K index)
CachecachedValueFor in interface Cache<K,V>public void finalize(V flushCandidate)
public boolean isFlushable(V flushCandidate)
public abstract V uncachedValueFor(K index)
CacheuncachedValueFor in interface Cache<K,V>public void clear()
Cachepublic java.util.List<V> listCachedValues()
CachelistCachedValues in interface Cache<K,V>public int getCapacity()
CachegetCapacity in interface Cache<K,V>public void setCapacity(int newSize)
CachesetCapacity in interface Cache<K,V>public boolean isManualFlushing()
public void setManualFlushing(boolean manualFlushing)
public boolean getUsingSeparateReaperThread()
public void setUsingSeparateReaperThread(boolean tizit)
public int compareTo(java.lang.Object nother)
compareTo in interface java.lang.Comparablepublic void flush()
public boolean remove(java.lang.Object index)
public int getByteSize()
CachegetByteSize in interface Cache<K,V>public int size()
Cache