Class LruBoundedCache<K,​V>

  • Direct Known Subclasses:
    ActorRefResolveCache, ActorRefResolveCacheWithAddress, SerializationFormatCache

    public abstract class LruBoundedCache<K,​V>
    extends java.lang.Object
    INTERNAL API

    This class is based on a Robin-Hood hashmap (http://www.sebastiansylvan.com/post/robin-hood-hashing-should-be-your-default-hash-table-implementation/) with backshift (http://codecapsule.com/2013/11/17/robin-hood-hashing-backward-shift-deletion/).

    The main modification compared to an RH hashmap is that it never grows the map (no rehashes) instead it is allowed to kick out entires that are considered old. The implementation tries to keep the map close to full, only evicting old entries when needed.

    • Constructor Detail

      • LruBoundedCache

        public LruBoundedCache​(int capacity,
                               int evictAgeThreshold,
                               scala.reflect.ClassTag<K> evidence$1,
                               scala.reflect.ClassTag<V> evidence$2)
    • Method Detail

      • compute

        protected abstract V compute​(K k)
      • get

        public final scala.Option<V> get​(K k)
      • getOrCompute

        public final V getOrCompute​(K k)
      • hash

        protected abstract int hash​(K k)
      • isCacheable

        protected abstract boolean isCacheable​(V v)
      • probeDistanceOf

        protected int probeDistanceOf​(int idealSlot,
                                      int actualSlot)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object