|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.shiro.util.SoftHashMap<K,V>
public class SoftHashMap<K,V>
A SoftHashMap
is a memory-constrained map that stores its values in
SoftReference
s. (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).
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry<K,V> |
Constructor Summary | |
---|---|
SoftHashMap()
Creates a new SoftHashMap with a default retention size size of DEFAULT_RETENTION_SIZE (100 entries). |
|
SoftHashMap(int retentionSize)
Creates a new SoftHashMap with the specified retention size. |
|
SoftHashMap(Map<K,V> source)
Creates a SoftHashMap backed by the specified source , with a default retention
size of DEFAULT_RETENTION_SIZE (100 entries). |
|
SoftHashMap(Map<K,V> source,
int retentionSize)
Creates a SoftHashMap backed by the specified source , with the specified retention size. |
Method Summary | |
---|---|
void |
clear()
|
boolean |
containsKey(Object key)
|
boolean |
containsValue(Object value)
|
Set<Map.Entry<K,V>> |
entrySet()
|
V |
get(Object key)
|
boolean |
isEmpty()
|
Set<K> |
keySet()
|
V |
put(K key,
V value)
Creates a new entry, but wraps the value in a SoftValue instance to enable auto garbage collection. |
void |
putAll(Map<? extends K,? extends V> m)
|
V |
remove(Object key)
|
int |
size()
|
Collection<V> |
values()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
equals, hashCode |
Constructor Detail |
---|
public SoftHashMap()
DEFAULT_RETENTION_SIZE
(100 entries).
SoftHashMap(int)
public SoftHashMap(int retentionSize)
retentionSize
value. This number is intended to be a best-effort retention low
water mark.
retentionSize
- the total number of most recent entries in the map that will be strongly referenced
(retained), preventing them from being eagerly garbage collected by the JVM.public SoftHashMap(Map<K,V> source)
SoftHashMap
backed by the specified source
, with a default retention
size of DEFAULT_RETENTION_SIZE
(100 entries).
source
- the backing map to populate this SoftHashMap
SoftHashMap(Map,int)
public SoftHashMap(Map<K,V> source, int retentionSize)
SoftHashMap
backed by the specified source
, with the specified retention size.
The retention size (n) is the total number of most recent entries in the map that will be strongly referenced
(ie 'retained') to prevent them from being eagerly garbage collected. That is, the point of a SoftHashMap is to
allow the garbage collector to remove as many entries from this map as it desires, but there will always be (n)
elements retained after a GC due to the strong references.
Note that in a highly concurrent environments the exact total number of strong references may differ slightly
than the actual retentionSize
value. This number is intended to be a best-effort retention low
water mark.
source
- the backing map to populate this SoftHashMap
retentionSize
- the total number of most recent entries in the map that will be strongly referenced
(retained), preventing them from being eagerly garbage collected by the JVM.Method Detail |
---|
public V get(Object key)
get
in interface Map<K,V>
public boolean isEmpty()
isEmpty
in interface Map<K,V>
public boolean containsKey(Object key)
containsKey
in interface Map<K,V>
public boolean containsValue(Object value)
containsValue
in interface Map<K,V>
public void putAll(Map<? extends K,? extends V> m)
putAll
in interface Map<K,V>
public Set<K> keySet()
keySet
in interface Map<K,V>
public Collection<V> values()
values
in interface Map<K,V>
public V put(K key, V value)
put
in interface Map<K,V>
public V remove(Object key)
remove
in interface Map<K,V>
public void clear()
clear
in interface Map<K,V>
public int size()
size
in interface Map<K,V>
public Set<Map.Entry<K,V>> entrySet()
entrySet
in interface Map<K,V>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |