Class LRUByteLimitedHashtable<K,​V>

  • Type Parameters:
    K - key type
    V - 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 of CapacityLimitedHashtable that 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>
      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long getObjectSize​(java.lang.Object obj)
      Estimates the size of the object in bytes.
      • 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
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • LRUByteLimitedHashtable

        public LRUByteLimitedHashtable​(long capacity)
        Parameters:
        capacity - Maximum capacity of this table in bytes
    • Method Detail

      • getObjectSize

        public long getObjectSize​(java.lang.Object obj)
        Estimates the size of the object in bytes. If obj is a byte[], this returns its length; if it implements Sizeable this uses getSizeInCache(). Returns 0 for all other objects.
        Specified by:
        getObjectSize in class CapacityLimitedHashtable<K,​V>
        Parameters:
        obj - Object to estimate the byte-size of
        Returns:
        estimated byte-size