|
ANTS v2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ants.core.NodeCache
Node cache of managed soft-state.
Combines hashtable and doubly linked list to implement fixed size table with LRU replacement. all public entry points are synchronized. a background gc thread cleans entries that have expired.
XXX the background GC thread is probably unnecessary since this is only per-flow state. At the least, the background thread should be configurable by the flow (e.g., its collection parameters).
XXX should this class be final? Should more methods be marked final? (e.g., get)
This differs from the original version in that it does not have a maximum time limit or a maximum number of cached items, both of which are unneeded because of per-flow resource limits.
Inner Class Summary | |
static class |
NodeCache.EventHandler
Elements of this type in the node cache will receive calls when one of a set of events occurs. |
Constructor Summary | |
NodeCache(Node owner,
int size)
Construct a new NodeCache. |
Method Summary | |
java.lang.Object |
get(int i)
Overloaded get method for integer keys. |
java.lang.Object |
get(long l)
Overloaded get method for long keys. |
java.lang.Object |
get(java.lang.Object key)
Return the value paired with a certain key |
java.lang.Object |
put(int i,
java.lang.Object value,
int time)
Overloaded put method for integer keys. |
java.lang.Object |
put(long l,
java.lang.Object value,
int time)
Overloaded put method for long keys. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value,
int time)
Add a key/value pair to the cache with a given expiration time. |
boolean |
refresh(java.lang.Object key,
int time)
|
java.lang.Object |
remove(java.lang.Object key)
Remove an association from the cache. |
void |
run()
Run forever, collecting expired objects. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public NodeCache(Node owner, int size)
XXX this probably shouldn't be public.
owner
- The Node that owns this NodeCache instancesize
- The size of the hash tableduration
- Maximum allowable expiration time for an associationMethod Detail |
public final java.lang.Object get(java.lang.Object key)
key
- The key to search forpublic final java.lang.Object put(java.lang.Object key, java.lang.Object value, int time)
key
- The key for identifying the valuevalue
- The value to be trackedtime
- The expiration time for this associationpublic boolean refresh(java.lang.Object key, int time)
public java.lang.Object remove(java.lang.Object key)
key
- Key for the association to removepublic final java.lang.Object get(int i)
public final java.lang.Object put(int i, java.lang.Object value, int time)
public final java.lang.Object get(long l)
public final java.lang.Object put(long l, java.lang.Object value, int time)
public void run()
public java.lang.String toString()
|
ANTS v2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |