com.sun.jmx.remote.opt.util
Class CacheMap
java.lang.Object
java.util.AbstractMap<K,V>
java.util.WeakHashMap
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.
|
Constructor Summary |
CacheMap(int nSoftReferences)
Create a CacheMap that can keep up to
nSoftReferences as soft references. |
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.
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.