Class Async.AsyncWeigher<K,​V>

  • All Implemented Interfaces:
    Weigher<K,​java.util.concurrent.CompletableFuture<V>>, java.io.Serializable
    Enclosing class:
    Async

    static final class Async.AsyncWeigher<K,​V>
    extends java.lang.Object
    implements Weigher<K,​java.util.concurrent.CompletableFuture<V>>, java.io.Serializable
    A weigher for asynchronous computations. When the value is being loaded this weigher returns 0 to indicate that the entry should not be evicted due to a size constraint. If the value is computed successfully the entry must be reinserted so that the weight is updated and the expiration timeouts reflect the value once present. This can be done safely using Map.replace(Object, Object, Object).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int weigh​(K key, java.util.concurrent.CompletableFuture<V> future)
      Returns the weight of a cache entry.
      (package private) java.lang.Object writeReplace()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AsyncWeigher

        AsyncWeigher​(Weigher<K,​V> delegate)
    • Method Detail

      • weigh

        public int weigh​(K key,
                         java.util.concurrent.CompletableFuture<V> future)
        Description copied from interface: Weigher
        Returns the weight of a cache entry. There is no unit for entry weights; rather they are simply relative to each other.
        Specified by:
        weigh in interface Weigher<K,​V>
        Parameters:
        key - the key to weigh
        future - the value to weigh
        Returns:
        the weight of the entry; must be non-negative
      • writeReplace

        java.lang.Object writeReplace()