Class SimpleSoftCache<K,V>
java.lang.Object
org.apache.camel.support.cache.SimpleSoftCache<K,V>
- Type Parameters:
K- type of the keyV- type of the value
- All Implemented Interfaces:
Map<K,V>
SimpleSoftCache is a simple implementation of a cache where values are soft references which allows the
Garbage Collector to clear the referents in response of a memory demand to potentially prevent
OutOfMemoryError. The entries where the referent is missing are removed lazily when they are accessed
directly or indirectly through the Map API. The implementation doesn't accept null values. Generally
speaking, the parameters of all the public methods must have a value otherwise a NullPointerException is
thrown.- See Also:
-
Nested Class Summary
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleSoftCache(Map<K, SoftReference<V>> delegate) Constructs aSimpleSoftCachewith the given underlying cache. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()voidforEach(BiConsumer<? super K, ? super V> action) booleanisEmpty()Returns true if this map contains no key-value mappings without considering if the soft references still have a referent set for the sake of simplicity and efficiency.keySet()voidputIfAbsent(K key, V value) booleanbooleanvoidreplaceAll(BiFunction<? super K, ? super V, ? extends V> function) intsize()values()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Map
equals, getOrDefault, hashCode
-
Constructor Details
-
SimpleSoftCache
Constructs aSimpleSoftCachewith the given underlying cache.- Parameters:
delegate- the underlying cache to which the modifications are applied to. Be aware that the implementation of the provided map must accept concurrent modifications to allow lazy evictions of empty references.
-
-
Method Details
-
size
-
isEmpty
-
containsKey
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V>
-
get
-
put
-
remove
-
putAll
-
clear
-
keySet
-
values
-
entrySet
-
forEach
-
replaceAll
- Specified by:
replaceAllin interfaceMap<K,V>
-
putIfAbsent
-
remove
-
replace
-
replace
-
computeIfAbsent
-
computeIfPresent
- Specified by:
computeIfPresentin interfaceMap<K,V>
-
compute
-
merge
-