com.tagtraum.perf.datastructures
Class LRUMapCache
java.lang.Object
|
+--com.tagtraum.perf.datastructures.LRUMapCache
- public class LRUMapCache
- extends java.lang.Object
Caches a Map with a LRU access strategy. 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.
Note that MapCache
provides a similiar implementation with exchangable
Cache
e.
- Version:
- $Id: $
- Author:
- Hendrik Schreiber
- See Also:
MapCache
Constructor Summary |
LRUMapCache(java.util.Map map,
int initialCapacity)
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 |
LRUMapCache
public LRUMapCache(java.util.Map map,
int initialCapacity)
- Creates a cached map with an initial capacity that will be
increased to the next power of 2
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