Package org.bedework.util.caching
Class FlushMap<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,V>
-
- org.bedework.util.caching.FlushMap<K,V>
-
- Type Parameters:
K- Key classV- Value class
- All Implemented Interfaces:
Serializable,Cloneable,Map<K,V>
public class FlushMap<K,V> extends HashMap<K,V>
A map which will be flushed after a certain time or when it reaches a certain size.- Author:
- douglm
- See Also:
- Serialized Form
-
-
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
Constructors Constructor Description FlushMap()Create a FlushMap with default maxize and flush period.FlushMap(int size)Create a FlushMap with given size, default maxize and flush period.FlushMap(int size, long flushTime, int maxSize)Create a FlushMap with specified size, maxsize and flush period.FlushMap(long flushTime, int maxSize)Create a FlushMap with default size and specified maxsize and flush period.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsKey(Object key)Vget(Object key)Vput(K key, V val)protected booleantestFlush()Override this to modify the behavior - perhaps to preserve some special entries.-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsValue, entrySet, forEach, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
-
-
-
Constructor Detail
-
FlushMap
public FlushMap()
Create a FlushMap with default maxize and flush period.
-
FlushMap
public FlushMap(int size)
Create a FlushMap with given size, default maxize and flush period.- Parameters:
size- initial size
-
FlushMap
public FlushMap(long flushTime, int maxSize)Create a FlushMap with default size and specified maxsize and flush period.- Parameters:
flushTime- millis - 0 means no flush timemaxSize- - 0 means no max size
-
FlushMap
public FlushMap(int size, long flushTime, int maxSize)Create a FlushMap with specified size, maxsize and flush period.- Parameters:
size- initial sizeflushTime- millis - 0 means no flush timemaxSize- - 0 means no max size
-
-
Method Detail
-
testFlush
protected boolean testFlush()
Override this to modify the behavior - perhaps to preserve some special entries.- Returns:
- true if we flushed.
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<K,V>- Overrides:
containsKeyin classHashMap<K,V>
-
-