net.spy.cache
Class DiskCache

java.lang.Object
  extended by java.util.AbstractMap<Serializable,Serializable>
      extended by net.spy.cache.DiskCache
All Implemented Interfaces:
Map<Serializable,Serializable>

public class DiskCache
extends AbstractMap<Serializable,Serializable>

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/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
DiskCache(String base)
          Get an DiskObject using the given directory.
DiskCache(String base, int lruCacheSize)
          Get a DiskCache using the given directory with a backing LRU cache of the specified size.
 
Method Summary
 Set<Map.Entry<Serializable,Serializable>> entrySet()
           
 Serializable get(Object key)
          Get an object from the cache.
 String getBaseDir()
          Get the base directory which this cache is watching.
 Serializable put(Serializable k, Serializable v)
          Store an object in the cache.
 
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 base)
Get an DiskObject using the given directory.


DiskCache

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

Parameters:
base - 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 Serializable put(Serializable k,
                        Serializable v)
Store an object in the cache.

Specified by:
put in interface Map<Serializable,Serializable>
Overrides:
put in class AbstractMap<Serializable,Serializable>
Parameters:
k - object key
v - value
Returns:
the old object stored in that location (if any)

get

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

Specified by:
get in interface Map<Serializable,Serializable>
Overrides:
get in class AbstractMap<Serializable,Serializable>
Returns:
the object, or null if there's no such object

entrySet

public Set<Map.Entry<Serializable,Serializable>> entrySet()
Specified by:
entrySet in interface Map<Serializable,Serializable>
Specified by:
entrySet in class AbstractMap<Serializable,Serializable>


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