Bees v0.5.0 API

bees.core
Class NodeCache

java.lang.Object
  |
  +--bees.core.NodeCache

public final class NodeCache
extends java.lang.Object

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-domain state. At the least, the background thread should be configurable by the domain (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-domain resource limits.

Author:
David Wetherall, Utah Janos Team

Inner Class Summary
static interface 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 NodeCache with the given values.
 
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
 Node getOwnerNode()
           
 java.lang.Object[] keys()
           
 java.lang.Object put(int i, java.lang.Object value, IntegerPermission time)
          Overloaded put method for integer keys.
 java.lang.Object put(long l, java.lang.Object value, IntegerPermission time)
          Overloaded put method for long keys.
 java.lang.Object put(java.lang.Object key, java.lang.Object value, IntegerPermission time)
          Add a key/value pair to the cache with a given expiration time.
 boolean refresh(java.lang.Object key, IntegerPermission time)
           
 java.lang.Object remove(java.lang.Object key)
          Remove an association from the cache.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NodeCache

public NodeCache(Node owner,
                 int size)
Construct a NodeCache with the given values.
Parameters:
owner - The Node that owns this NodeCache instance
size - The size of the hash table
Method Detail

getOwnerNode

public final Node getOwnerNode()

get

public final java.lang.Object get(java.lang.Object key)
Return the value paired with a certain key
Parameters:
key - The key to search for
Returns:
The value associated with the key

put

public final java.lang.Object put(java.lang.Object key,
                                  java.lang.Object value,
                                  IntegerPermission time)
Add a key/value pair to the cache with a given expiration time. If the key is already present in the cache then it will be replaced with the parameters and the old value returned.
Parameters:
key - The key for identifying the value
value - The value to be tracked
time - The expiration time for this association
Returns:
Old value from a prior association, if it existed

refresh

public boolean refresh(java.lang.Object key,
                       IntegerPermission time)

remove

public java.lang.Object remove(java.lang.Object key)
Remove an association from the cache.
Parameters:
key - Key for the association to remove
Returns:
The value from the association

get

public final java.lang.Object get(int i)
Overloaded get method for integer keys.

put

public final java.lang.Object put(int i,
                                  java.lang.Object value,
                                  IntegerPermission time)
Overloaded put method for integer keys.

get

public final java.lang.Object get(long l)
Overloaded get method for long keys.

put

public final java.lang.Object put(long l,
                                  java.lang.Object value,
                                  IntegerPermission time)
Overloaded put method for long keys.

keys

public final java.lang.Object[] keys()
Returns:
The set of keys currently in the cache.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

Bees v0.5.0 API

This documentation is Copyright (C) 2002 The University of Utah. All Rights Reserved. See the individual source files for distribution terms.
Documentation, software, and mailing lists for Bees v0.5.0 can be found at the Janos Project: http://www.cs.utah.edu/flux/janos/