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.
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
CacheMap(int nSoftReferences)
Create a
CacheMap that can keep up to
nSoftReferences as soft references. |
| Modifier and Type | Method and Description |
|---|---|
Object |
get(Object key) |
Object |
put(Object key,
Object value) |
clear, containsKey, containsValue, entrySet, forEach, isEmpty, keySet, putAll, remove, replaceAll, size, valuesclone, equals, hashCode, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, equals, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replacepublic CacheMap(int nSoftReferences)
Create a CacheMap that can keep up to
nSoftReferences as soft references.
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.IllegalArgumentException - if
nSoftReferences is negative.Copyright © 2019 Terracotta, Inc.. All rights reserved.