Module swim.util
Package swim.util

Class HashGenMap<K,​V>


  • public class HashGenMap<K,​V>
    extends Object
    A hashed generational map evicts the least recently used value with the worst hit rate per hash bucket. HashGenMap is a concurrent and lock-free LRFU cache, with O(1) access time, that strongly references its values. Maintaining four "generations" of cached values per hash bucket, the cache discards from the younger generations based on least recent usage, and promotes younger generations to older generations based on most frequent usage. Cache misses count as negative usage of the older generations, biasing the cache against least recently used values with poor hit rates. The evict(K, V) method is guaranteed to be called when a value is displaced from the cache.
    • Constructor Detail

      • HashGenMap

        public HashGenMap​(int size)
    • Method Detail

      • evict

        protected void evict​(K key,
                             V value)
      • get

        public V get​(K key)
      • put

        public V put​(K key,
                     V value)
      • remove

        public V remove​(K key)
      • clear

        public void clear()
      • hits

        public long hits()
      • hitRatio

        public double hitRatio()