Class SoftHashMap<K,V>

java.lang.Object
com.okta.sdk.impl.util.SoftHashMap<K,V>
All Implemented Interfaces:
Map<K,V>

public class SoftHashMap<K,V> extends Object implements Map<K,V>
A SoftHashMap is a memory-constrained map that stores its values in SoftReferences. (Contrast this with the JDK's WeakHashMap, which uses weak references for its keys, which is of little value if you want the cache to auto-resize itself based on memory constraints).

Having the values wrapped by soft references allows the cache to automatically reduce its size based on memory limitations and garbage collection. This ensures that the cache will not cause memory leaks by holding strong references to all of its values.

This class is a generics-enabled Map based on initial ideas from Heinz Kabutz's and Sydney Redelinghuys's publicly posted version (with their approval), with continued modifications. It was copied from the Apache Shiro framework.

This implementation is thread-safe and usable in concurrent environments.

Since:
0.5.0
See Also: