public class TimedReferenceMap<V> extends ReferenceMap<Object,V>
ReferenceMap of apache commons is overwritten to add temporarily hard references. If a new object was
added (to a weak map), but a reference will be created some milliseconds later, the value may be garbage collected
already. This map holds a collection - the TimedReferences to don't lose the object to early.
To set the duration of the hard references, call setTimeToBeOld(long), giving the milliseconds to hold an
object at least.
Only the put(Object, Object) method was overridden, AbstractMap.putAll(java.util.Map) should call this
put(Object, Object) method. Removing values will not change the TimedReferences!AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
TimedReferenceMap()
constructor
|
TimedReferenceMap(boolean weak)
constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
V |
put(Object key,
V value) |
void |
removeOldReferences()
removeOldReferences
|
void |
setTimeToBeOld(long timeToBeOld)
setTimeToBeOld - time to be hold
|
createReference, entrySet, get, remove, sizeclone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, toString, valuesfinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAllpublic TimedReferenceMap()
public TimedReferenceMap(boolean weak)
weak - Copyright © 2012–2018. All rights reserved.