com.tagtraum.perf.datastructures
Class MapCache

java.lang.Object
  |
  +--com.tagtraum.perf.datastructures.MapCache

public class MapCache
extends java.lang.Object

Caches a Map. Do not use this Cache for caching a HashMap. You may get positive results for caching a TreeMap depending on the size of the TreeMap, the capacity of this cache and the quality of the hashcodes of the cached objects.

Version:
$Id: $
Author:
Hendrik Schreiber

Constructor Summary
MapCache(java.util.Map map, Cache cache)
          Creates a cached map with an initial capacity that will be increased to the next power of 2
 
Method Summary
 java.lang.Object get(java.lang.Object key)
           
 int getCapacity()
           
 float getHitRatio()
           
 java.util.Map getMap()
          Returns an unmodifiable view of the underlying map, so that modifications of the map have to happen through the cached map.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapCache

public MapCache(java.util.Map map,
                Cache cache)
Creates a cached map with an initial capacity that will be increased to the next power of 2

Method Detail

getCapacity

public int getCapacity()

getMap

public java.util.Map getMap()
Returns an unmodifiable view of the underlying map, so that modifications of the map have to happen through the cached map.


get

public java.lang.Object get(java.lang.Object key)

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)

getHitRatio

public float getHitRatio()


Copyright © 2002 Hendrik Schreiber
http://www.tagtraum.com/performance/
This software can be distributed under LGPL