net.spy.cache
Class DiskCache

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

public class DiskCache
extends java.util.AbstractMap<java.io.Serializable,java.io.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
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<java.util.Map.Entry<java.io.Serializable,java.io.Serializable>> entrySet()
           
 java.io.Serializable 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.io.Serializable put(java.io.Serializable k, java.io.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(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.io.Serializable put(java.io.Serializable k,
                                java.io.Serializable v)
Store an object in the cache.

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

get

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

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

entrySet

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


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