com.sun.jmx.remote.opt.util
Class CacheMap

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.WeakHashMap
          extended by com.sun.jmx.remote.opt.util.CacheMap
All Implemented Interfaces:
Map

public class CacheMap
extends WeakHashMap

Like WeakHashMap, except that the keys of the n most recently-accessed entries are kept as soft references. Accessing an element means creating it, or retrieving it with get. Because these entries are kept with soft references, they will tend to remain even if their keys are not referenced elsewhere. But if memory is short, they will be removed.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
CacheMap(int nSoftReferences)
          Create a CacheMap that can keep up to nSoftReferences as soft references.
 
Method Summary
 Object get(Object key)
           
 Object put(Object key, Object value)
           
 
Methods inherited from class java.util.WeakHashMap
clear, containsKey, containsValue, entrySet, isEmpty, keySet, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
clone, equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

CacheMap

public CacheMap(int nSoftReferences)

Create a CacheMap that can keep up to nSoftReferences as soft references.

Parameters:
nSoftReferences - Maximum number of keys to keep as soft references. Access times for get and put have a component that scales linearly with nSoftReferences, so this value should not be too great.
Throws:
IllegalArgumentException - if nSoftReferences is negative.
Method Detail

put

public Object put(Object key,
                  Object value)
Specified by:
put in interface Map
Overrides:
put in class WeakHashMap

get

public Object get(Object key)
Specified by:
get in interface Map
Overrides:
get in class WeakHashMap


Copyright © 2014 Terracotta, Inc.. All rights reserved.