Class CachingMap<T>
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<String,SoftReference<T>>
org.apache.sling.scripting.core.impl.helper.CachingMap<T>
- Type Parameters:
T- the type to whichSoftReferences will be kept
- All Implemented Interfaces:
Serializable,Cloneable,Map<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.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Constructor Summary
ConstructorsConstructorDescriptionCachingMap(int capacity) Creates a caching map with a maximum capacity equal to thecapacityparameter. -
Method Summary
Modifier and TypeMethodDescriptionbooleaninthashCode()protected booleanremoveEldestEntry(Map.Entry<String, SoftReference<T>> eldest) Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, replaceAll, valuesMethods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeMethods inherited from class java.util.AbstractMap
toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
Constructor Details
-
CachingMap
public CachingMap(int capacity) Creates a caching map with a maximum capacity equal to thecapacityparameter.- Parameters:
capacity- the maximum capacity; ifcapacity < 1then this map will always remove the latest added element
-
-
Method Details
-
removeEldestEntry
- Overrides:
removeEldestEntryin classLinkedHashMap<String,SoftReference<T>>
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceMap<String,SoftReference<T>> - Overrides:
hashCodein classAbstractMap<String,SoftReference<T>>
-
equals
- Specified by:
equalsin interfaceMap<String,SoftReference<T>> - Overrides:
equalsin classAbstractMap<String,SoftReference<T>>
-