org.cdlib.xtf.cache
Class StringCache

Object
  extended by Cache<K,V>
      extended by SimpleCache
          extended by StringCache

public class StringCache
extends SimpleCache

This class caches mappings from a string to a string.


Nested Class Summary
 
Nested classes/interfaces inherited from class Cache
Cache.ListEntry, Cache.NullIterator
 
Field Summary
 String cacheName
          Name of the cache, printed by logAction()
 
Fields inherited from class Cache
ageList, keyMap
 
Constructor Summary
StringCache(String cacheName, int maxEntries, int maxTime)
          Constructor - establishes the cache.
 
Method Summary
 String get(String key)
          Get the value corresponding to the given key
protected  void logAction(String action, Object key, Object value)
          Print out useful debug info
 
Methods inherited from class SimpleCache
addDependency, get, set, set
 
Methods inherited from class Cache
cleanup, clear, dependenciesValid, getDependencies, has, lastSet, remove, size
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cacheName

public String cacheName
Name of the cache, printed by logAction()

Constructor Detail

StringCache

public StringCache(String cacheName,
                   int maxEntries,
                   int maxTime)
Constructor - establishes the cache.

Parameters:
cacheName - Name to print out in logAction()
maxEntries - Max # of entries before old ones are flushed.
maxTime - Max age (in seconds) of entries before flushed.
Method Detail

get

public String get(String key)
Get the value corresponding to the given key

Parameters:
key - The key to look for
Returns:
Corresponding value, or null if key not found.

logAction

protected void logAction(String action,
                         Object key,
                         Object value)
Print out useful debug info

Overrides:
logAction in class Cache
Parameters:
action - What happened ("Added", "Removed", etc.)
key - The key involved in the action
value - The value involved in the action