net.spy.cache
Class DiskCache

java.lang.Object
  extended byjava.util.AbstractMap
      extended bynet.spy.cache.DiskCache
All Implemented Interfaces:
Map

public class DiskCache
extends AbstractMap

Simple local disk caching. This is used for terribly simple caches with no expiration dates on objects. Things go in and they stay in.


Nested Class Summary
 
Nested classes inherited from class java.util.Map
Map.Entry
 
Constructor Summary
DiskCache(String basedir)
          Get an DiskObject using the given directory.
DiskCache(String basedir, int lruCacheSize)
          Get a DiskCache using the given directory with a backing LRU cache of the specified size.
 
Method Summary
 Set entrySet()
           
 Object get(Object key)
          Get an object from the cache.
 String getBaseDir()
          Get the base directory which this cache is watching.
 Object getObject(String key)
          Deprecated. use get(Object) instead
 Object put(Object k, Object v)
          Store an object in the cache.
 void storeObject(String key, Object o)
          Deprecated. use put(Object,Object) instead
 
Methods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DiskCache

public DiskCache(String basedir)
Get an DiskObject using the given directory.


DiskCache

public DiskCache(String basedir,
                 int lruCacheSize)
Get a DiskCache using the given directory with a backing LRU cache of the specified size.

Parameters:
basedir - the base directory for the disk cache
lruCacheSize - the size of the LRU cache holding recently accessed objects
Method Detail

getBaseDir

public String getBaseDir()
Get the base directory which this cache is watching.


put

public Object put(Object k,
                  Object v)
Store an object in the cache.

Parameters:
k - object key
v - value
Returns:
the old object stored in that location (if any)

storeObject

public void storeObject(String key,
                        Object o)
                 throws IOException
Deprecated. use put(Object,Object) instead

Old API for storing.

Throws:
IOException

get

public Object get(Object key)
Get an object from the cache.

Returns:
the object, or null if there's no such object

entrySet

public Set entrySet()

getObject

public Object getObject(String key)
Deprecated. use get(Object) instead

Old API for getting objects.