Package com.snowbound.common.utils
Class LRUByteLimitedHashtable<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.concurrent.ConcurrentHashMap<K,V>
-
- com.snowbound.common.utils.CapacityLimitedHashtable<K,V>
-
- com.snowbound.common.utils.LRUByteLimitedHashtable<K,V>
-
- Type Parameters:
K- key typeV- value type
- All Implemented Interfaces:
java.io.Serializable,java.util.concurrent.ConcurrentMap<K,V>,java.util.Map<K,V>
public class LRUByteLimitedHashtable<K,V> extends CapacityLimitedHashtable<K,V>
Implementation ofCapacityLimitedHashtablethat attempts to keep its contents to a specific size in memory by ejecting least-recently-used items when reaching its maximum capacity. It allows any values, but values should be a byte[] or implement the Sizeable interface for byte-size estimation to function.- See Also:
CapacityLimitedHashtable, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.concurrent.ConcurrentHashMap
java.util.concurrent.ConcurrentHashMap.KeySetView<K extends java.lang.Object,V extends java.lang.Object>
-
-
Constructor Summary
Constructors Constructor Description LRUByteLimitedHashtable(long capacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetObjectSize(java.lang.Object obj)Estimates the size of the object in bytes.-
Methods inherited from class com.snowbound.common.utils.CapacityLimitedHashtable
currentSize, get, put, remove
-
Methods inherited from class java.util.concurrent.ConcurrentHashMap
clear, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, forEach, forEach, forEachEntry, forEachEntry, forEachKey, forEachKey, forEachValue, forEachValue, getOrDefault, hashCode, isEmpty, keys, keySet, keySet, mappingCount, merge, newKeySet, newKeySet, putAll, putIfAbsent, reduce, reduceEntries, reduceEntries, reduceEntriesToDouble, reduceEntriesToInt, reduceEntriesToLong, reduceKeys, reduceKeys, reduceKeysToDouble, reduceKeysToInt, reduceKeysToLong, reduceToDouble, reduceToInt, reduceToLong, reduceValues, reduceValues, reduceValuesToDouble, reduceValuesToInt, reduceValuesToLong, remove, replace, replace, replaceAll, search, searchEntries, searchKeys, searchValues, size, toString, values
-
-
-
-
Method Detail
-
getObjectSize
public long getObjectSize(java.lang.Object obj)
Estimates the size of the object in bytes. Ifobjis a byte[], this returns its length; if it implementsSizeablethis usesgetSizeInCache(). Returns 0 for all other objects.- Specified by:
getObjectSizein classCapacityLimitedHashtable<K,V>- Parameters:
obj- Object to estimate the byte-size of- Returns:
- estimated byte-size
-
-