|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.partnersoft.gadgets.HashedCache<K,V>
public abstract class HashedCache<K,V>
A fixed-size caching implementation based on a hashed index.
Copyright 1998-2009 Partner Software, Inc.
| Field Summary | |
|---|---|
static int |
DEFAULTSIZE
|
| Constructor Summary | |
|---|---|
HashedCache()
Create a hashed cache of the default size, 42. |
|
HashedCache(int size)
Create a hashed cache of the desired size. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULTSIZE
| Constructor Detail |
|---|
public HashedCache()
public HashedCache(int size)
| Method Detail |
|---|
public V cachedValueFor(K index)
Cache
cachedValueFor in interface Cache<K,V>public void finalize(V flushCandidate)
public boolean isFlushable(V flushCandidate)
public abstract V uncachedValueFor(K index)
Cache
uncachedValueFor in interface Cache<K,V>public void clear()
Cache
clear in interface Cache<K,V>public java.util.List<V> listCachedValues()
Cache
listCachedValues in interface Cache<K,V>public int getCapacity()
Cache
getCapacity in interface Cache<K,V>public void setCapacity(int newSize)
Cache
setCapacity 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()
Cache
getByteSize in interface Cache<K,V>public int size()
Cache
size in interface Cache<K,V>public java.lang.String getName()
getName in interface Cache<K,V>
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||