Class Async.AsyncExpiry<K,​V>

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

    static final class Async.AsyncExpiry<K,​V>
    extends java.lang.Object
    implements Expiry<K,​java.util.concurrent.CompletableFuture<V>>, java.io.Serializable
    An expiry for asynchronous computations. When the value is being loaded this expiry returns ASYNC_EXPIRY to indicate that the entry should not be evicted due to an expiry constraint. If the value is computed successfully the entry must be reinserted so that the expiration is updated and the expiration timeouts reflect the value once present. The value maximum range is reserved to coordinate the asynchronous life cycle.
    • Constructor Summary

      Constructors 
      Constructor Description
      AsyncExpiry​(Expiry<K,​V> delegate)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long expireAfterCreate​(K key, java.util.concurrent.CompletableFuture<V> future, long currentTime)
      Specifies that the entry should be automatically removed from the cache once the duration has elapsed after the entry's creation.
      long expireAfterRead​(K key, java.util.concurrent.CompletableFuture<V> future, long currentTime, long currentDuration)
      Specifies that the entry should be automatically removed from the cache once the duration has elapsed after its last read.
      long expireAfterUpdate​(K key, java.util.concurrent.CompletableFuture<V> future, long currentTime, long currentDuration)
      Specifies that the entry should be automatically removed from the cache once the duration has elapsed after the replacement of its value.
      (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

      • AsyncExpiry

        AsyncExpiry​(Expiry<K,​V> delegate)
    • Method Detail

      • expireAfterCreate

        public long expireAfterCreate​(K key,
                                      java.util.concurrent.CompletableFuture<V> future,
                                      long currentTime)
        Description copied from interface: Expiry
        Specifies that the entry should be automatically removed from the cache once the duration has elapsed after the entry's creation. To indicate no expiration an entry may be given an excessively long period, such as Long#MAX_VALUE.

        Note: The currentTime is supplied by the configured Ticker and by default does not relate to system or wall-clock time. When calculating the duration based on a time stamp, the current time should be obtained independently.

        Specified by:
        expireAfterCreate in interface Expiry<K,​V>
        Parameters:
        key - the key represented by this entry
        future - the value represented by this entry
        currentTime - the current time, in nanoseconds
        Returns:
        the length of time before the entry expires, in nanoseconds
      • expireAfterUpdate

        public long expireAfterUpdate​(K key,
                                      java.util.concurrent.CompletableFuture<V> future,
                                      long currentTime,
                                      long currentDuration)
        Description copied from interface: Expiry
        Specifies that the entry should be automatically removed from the cache once the duration has elapsed after the replacement of its value. To indicate no expiration an entry may be given an excessively long period, such as Long#MAX_VALUE. The currentDuration may be returned to not modify the expiration time.

        Note: The currentTime is supplied by the configured Ticker and by default does not relate to system or wall-clock time. When calculating the duration based on a time stamp, the current time should be obtained independently.

        Specified by:
        expireAfterUpdate in interface Expiry<K,​V>
        Parameters:
        key - the key represented by this entry
        future - the value represented by this entry
        currentTime - the current time, in nanoseconds
        currentDuration - the current duration, in nanoseconds
        Returns:
        the length of time before the entry expires, in nanoseconds
      • expireAfterRead

        public long expireAfterRead​(K key,
                                    java.util.concurrent.CompletableFuture<V> future,
                                    long currentTime,
                                    long currentDuration)
        Description copied from interface: Expiry
        Specifies that the entry should be automatically removed from the cache once the duration has elapsed after its last read. To indicate no expiration an entry may be given an excessively long period, such as Long#MAX_VALUE. The currentDuration may be returned to not modify the expiration time.

        Note: The currentTime is supplied by the configured Ticker and by default does not relate to system or wall-clock time. When calculating the duration based on a time stamp, the current time should be obtained independently.

        Specified by:
        expireAfterRead in interface Expiry<K,​V>
        Parameters:
        key - the key represented by this entry
        future - the value represented by this entry
        currentTime - the current time, in nanoseconds
        currentDuration - the current duration, in nanoseconds
        Returns:
        the length of time before the entry expires, in nanoseconds
      • writeReplace

        java.lang.Object writeReplace()