net.spy.cache
Class SpyCache

java.lang.Object
  extended by net.spy.SpyObject
      extended by net.spy.cache.SpyCache

public class SpyCache
extends SpyObject

Spy in-memory cache object.

If the system properties net.spy.cache.multi.addr and net.spy.cache.multi.port are both set, requests may be sent as ASCII strings on that multicast group and port to clear cache entries based on prefix.


Constructor Summary
protected SpyCache()
          Construct a new instance of SpyCache.
 
Method Summary
 Object get(String key)
          Get an object from the cache, returns null if there's not a valid object in the cache with this key.
static SpyCache getInstance()
          Get the instance of SpyCache.
 void setDelegate(CacheDelegate del)
          Set the delegate for this SpyCache.
static void shutdown()
          Shut down the cache.
 void store(String key, Cachable value)
          Store a Cachable object in the cache.
 void store(String key, Object value, long cacheTime)
          Store an object in the cache with the specified timeout.
 void uncache(String key)
          Manually remove an object from the cache.
 void uncacheLike(String keystart)
          Remove all objects from the cache that begin with the passed in string.
 
Methods inherited from class net.spy.SpyObject
getLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpyCache

protected SpyCache()
Construct a new instance of SpyCache. This allows subclasses to override certain methods, allowing smarter cache handling.

Method Detail

getInstance

public static SpyCache getInstance()
Get the instance of SpyCache.

Returns:
the instance of SpyCache, or a new instance if required

shutdown

public static void shutdown()
Shut down the cache.


setDelegate

public void setDelegate(CacheDelegate del)
Set the delegate for this SpyCache.

Parameters:
del -

store

public void store(String key,
                  Cachable value)
Store a Cachable object in the cache.

Parameters:
key - the key for storing this object
value - the object to store

store

public void store(String key,
                  Object value,
                  long cacheTime)
Store an object in the cache with the specified timeout.

Objects will be wrapped in a private subclass of Cachable that expires based on the time.

Parameters:
key - Cache key
value - Object to cache
cacheTime - Amount of time (in milliseconds) to store object.

get

public Object get(String key)
Get an object from the cache, returns null if there's not a valid object in the cache with this key.

Parameters:
key - key of the object to return
Returns:
the object, else null

uncache

public void uncache(String key)
Manually remove an object from the cache.

Parameters:
key - key to remove

uncacheLike

public void uncacheLike(String keystart)
Remove all objects from the cache that begin with the passed in string.

Parameters:
keystart - string to match in the key name


Copyright © 1995-2007 SPY Internetworking. All Rights Reserved.