org.shiftone.cache.adaptor
Class MapCache

java.lang.Object
  extended byorg.shiftone.cache.adaptor.MapCache
All Implemented Interfaces:
Cache

public class MapCache
extends java.lang.Object
implements Cache

Makes a map look like a shiftone cache.

Version:
$Revision: 1.8 $
Author:
Jeff Drost

Constructor Summary
MapCache()
           
MapCache(java.util.Map map)
           
MapCache(java.util.Map map, java.lang.String name)
           
 
Method Summary
 void addObject(java.lang.Object key, java.lang.Object cacheObject)
          adds an object to the cache
 void clear()
          Removes ALL keys and values from the cache.
static Cache createLinkedHashMapCache(int size)
          The Java Developers Almanac 1.4 e344.
 java.lang.Object getObject(java.lang.Object key)
          gets the value stored in the cache by it's key, or null if the key is not found.
 void remove(java.lang.Object key)
          remove a specific key/value pair from the cache
 int size()
          The number of key/value pares in the cache
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MapCache

public MapCache()

MapCache

public MapCache(java.util.Map map)

MapCache

public MapCache(java.util.Map map,
                java.lang.String name)
Method Detail

createLinkedHashMapCache

public static Cache createLinkedHashMapCache(int size)
The Java Developers Almanac 1.4 e344. Implementing a Least-Recently-Used (LRU) Cache http://javaalmanac.com/egs/java.util/coll_Cache.html


addObject

public void addObject(java.lang.Object key,
                      java.lang.Object cacheObject)
Description copied from interface: Cache
adds an object to the cache

Specified by:
addObject in interface Cache

getObject

public java.lang.Object getObject(java.lang.Object key)
Description copied from interface: Cache
gets the value stored in the cache by it's key, or null if the key is not found.

Specified by:
getObject in interface Cache

size

public int size()
Description copied from interface: Cache
The number of key/value pares in the cache

Specified by:
size in interface Cache

remove

public void remove(java.lang.Object key)
Description copied from interface: Cache
remove a specific key/value pair from the cache

Specified by:
remove in interface Cache

clear

public void clear()
Description copied from interface: Cache
Removes ALL keys and values from the cache. Use with digression. Using this method too frequently may defeat the purpose of caching.

Specified by:
clear in interface Cache

toString

public java.lang.String toString()