Class PassiveExpiringMap.ConstantTimeToLiveExpirationPolicy<K,​V>

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long expirationTime​(K key, V value)
      Determine the expiration time for the given key-value entry.
      • Methods inherited from class java.lang.Object

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

      • ConstantTimeToLiveExpirationPolicy

        public ConstantTimeToLiveExpirationPolicy()
        Default constructor. Constructs a policy using a negative time-to-live value that results in entries never expiring.
      • ConstantTimeToLiveExpirationPolicy

        public ConstantTimeToLiveExpirationPolicy​(long timeToLiveMillis)
        Construct a policy with the given time-to-live constant measured in milliseconds. A negative time-to-live value indicates entries never expire. A zero time-to-live value indicates entries expire (nearly) immediately.
        Parameters:
        timeToLiveMillis - the constant amount of time (in milliseconds) an entry is available before it expires. A negative value results in entries that NEVER expire. A zero value results in entries that ALWAYS expire.
      • ConstantTimeToLiveExpirationPolicy

        public ConstantTimeToLiveExpirationPolicy​(long timeToLive,
                                                  java.util.concurrent.TimeUnit timeUnit)
        Construct a policy with the given time-to-live constant measured in the given time unit of measure.
        Parameters:
        timeToLive - the constant amount of time an entry is available before it expires. A negative value results in entries that NEVER expire. A zero value results in entries that ALWAYS expire.
        timeUnit - the unit of time for the timeToLive parameter, must not be null.
        Throws:
        java.lang.NullPointerException - if the time unit is null.
    • Method Detail

      • expirationTime

        public long expirationTime​(K key,
                                   V value)
        Determine the expiration time for the given key-value entry.
        Specified by:
        expirationTime in interface PassiveExpiringMap.ExpirationPolicy<K,​V>
        Parameters:
        key - the key for the entry (ignored).
        value - the value for the entry (ignored).
        Returns:
        if timeToLiveMillis ≥ 0, an expiration time of timeToLiveMillis + System.currentTimeMillis() is returned. Otherwise, -1 is returned indicating the entry never expires.