net.spy.cache
Class DiskCache

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

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


DiskCache

public DiskCache(java.lang.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 java.lang.String getBaseDir()
Get the base directory which this cache is watching.


put

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

Specified by:
put in interface java.util.Map
Overrides:
put in class java.util.AbstractMap
Parameters:
k - object key
v - value
Returns:
the old object stored in that location (if any)

get

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

Specified by:
get in interface java.util.Map
Overrides:
get in class java.util.AbstractMap
Returns:
the object, or null if there's no such object

entrySet

public java.util.Set entrySet()
Specified by:
entrySet in interface java.util.Map
Specified by:
entrySet in class java.util.AbstractMap


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