| Modifier and Type | Method and Description | 
|---|---|
| default Optional<Duration> | ageOf(K key)Returns the age of the entry based on the expiration policy. | 
| OptionalLong | ageOf(K key,
     TimeUnit unit)Returns the age of the entry based on the expiration policy. | 
| default Duration | getExpiresAfter()Returns the fixed duration used to determine if an entry should be automatically removed due
 to elapsing this time bound. | 
| long | getExpiresAfter(TimeUnit unit)Returns the fixed duration used to determine if an entry should be automatically removed due
 to elapsing this time bound. | 
| Map<K,V> | oldest(int limit)Returns an unmodifiable snapshot  Mapview of the cache with ordered traversal. | 
| default void | setExpiresAfter(Duration duration)Specifies that each entry should be automatically removed from the cache once a fixed
 duration has elapsed. | 
| void | setExpiresAfter(long duration,
               TimeUnit unit)Specifies that each entry should be automatically removed from the cache once a fixed
 duration has elapsed. | 
| Map<K,V> | youngest(int limit)Returns an unmodifiable snapshot  Mapview of the cache with ordered traversal. | 
@Nonnull OptionalLong ageOf(@Nonnull K key, @Nonnull TimeUnit unit)
 An expiration policy uses the age to determine if an entry is fresh or stale by comparing it
 to the freshness lifetime. This is calculated as fresh = freshnessLifetime > age
 where freshnessLifetime = expires - currentTime.
 
This method is scheduled for removal in version 3.0.0.
key - the key for the entry being queriedunit - the unit that age is expressed in@Nonnull default Optional<Duration> ageOf(@Nonnull K key)
 An expiration policy uses the age to determine if an entry is fresh or stale by comparing it
 to the freshness lifetime. This is calculated as fresh = freshnessLifetime > age
 where freshnessLifetime = expires - currentTime.
key - the key for the entry being queried@Nonnegative long getExpiresAfter(@Nonnull TimeUnit unit)
This method is scheduled for removal in version 3.0.0.
unit - the unit that duration is expressed in@Nonnull default Duration getExpiresAfter()
void setExpiresAfter(@Nonnegative long duration, @Nonnull TimeUnit unit)
This method is scheduled for removal in version 3.0.0.
duration - the length of time after which an entry should be automatically removedunit - the unit that duration is expressed inIllegalArgumentException - if duration is negativedefault void setExpiresAfter(@Nonnull Duration duration)
duration - the length of time after which an entry should be automatically removedIllegalArgumentException - if duration is negative@Nonnull Map<K,V> oldest(@Nonnegative int limit)
Map view of the cache with ordered traversal. The
 order of iteration is from the entries most likely to expire (oldest) to the entries least
 likely to expire (youngest). This order is determined by the expiration policy's best guess
 at the time of creating this snapshot view.
 Beware that obtaining the mappings is NOT a constant-time operation. Because of the asynchronous nature of the page replacement policy, determining the retention ordering requires a traversal of the entries.
limit - the maximum size of the returned map (use Integer.MAX_VALUE to disregard
        the limit)@Nonnull Map<K,V> youngest(@Nonnegative int limit)
Map view of the cache with ordered traversal. The
 order of iteration is from the entries least likely to expire (youngest) to the entries most
 likely to expire (oldest). This order is determined by the expiration policy's best guess at
 the time of creating this snapshot view.
 Beware that obtaining the mappings is NOT a constant-time operation. Because of the asynchronous nature of the page replacement policy, determining the retention ordering requires a traversal of the entries.
limit - the maximum size of the returned map (use Integer.MAX_VALUE to disregard
        the limit)