T - the type to which SoftReferences will be keptpublic class CachingMap<T> extends LinkedHashMap<String,SoftReference<T>>
The CachingMap class offers an implementation of a LinkedHashMap that can be used for caches. The maps' values are
SoftReferences, such that garbage collection can be performed on the cache, if needed.
Read / write operations are NOT synchronised.
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
CachingMap(int capacity)
Creates a caching map with a maximum capacity equal to the
capacity parameter. |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
removeEldestEntry(Map.Entry<String,SoftReference<T>> eldest) |
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, replaceAll, valuesclone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeequals, hashCode, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, sizepublic CachingMap(int capacity)
capacity parameter.capacity - the maximum capacity; if capacity < 1 then this map will always remove the latest added elementprotected boolean removeEldestEntry(Map.Entry<String,SoftReference<T>> eldest)
removeEldestEntry in class LinkedHashMap<String,SoftReference<T>>Copyright © 2007–2018 The Apache Software Foundation. All rights reserved.