guava/src/com/google/common/cache/CacheBuilder.java
@J2ObjCIncompatible
  @GwtIncompatible // java.time.Duration
  @SuppressWarnings("GoodTime") // java.time.Duration decomposition
  public CacheBuilder<K, V> expireAfterWrite(java.time.Duration duration) {
    return expireAfterWrite(duration.toNanos(), TimeUnit.NANOSECONDS);
  }
@J2ObjCIncompatible
  @GwtIncompatible // java.time.Duration
  @SuppressWarnings("GoodTime") // java.time.Duration decomposition
  public CacheBuilder<K, V> expireAfterWrite(java.time.Duration duration) {
    return expireAfterWrite(duration.toNanos(), TimeUnit.NANOSECONDS);
  }
@ J2ObjCIncompatible @ GwtIncompatible // java.time.Duration @ SuppressWarnings ( "GoodTime" ) // java.time.Duration decomposition public CacheBuilder < K , V > expireAfterWrite ( java . time . Duration duration ) { return expireAfterWrite ( duration . toNanos ( ) , TimeUnit . NANOSECONDS ) ; }
Specifies that each entry should be automatically removed from the cache once a fixed duration
has elapsed after the entry's creation, or the most recent replacement of its value.

<p>When {@code duration} is zero, this method hands off to {@link #maximumSize(long)
maximumSize}{@code (0)}, ignoring any otherwise-specified maximum size or weight. This can be
useful in testing, or to disable caching temporarily without a code change.

<p>Expired entries may be counted in {@link Cache#size}, but will never be visible to read or
write operations. Expired entries are cleaned up as part of the routine maintenance described
in the class javadoc.

@param duration the length of time after an entry is created that it should be automatically
removed
@return this {@code CacheBuilder} instance (for chaining)
@throws IllegalArgumentException if {@code duration} is negative
@throws IllegalStateException if the time to live or time to idle was already set
@throws ArithmeticException for durations greater than +/- approximately 292 years
@since 25.0
Specifies that each entry should be automatically removed from the cache once a fixed duration has elapsed after the entry s creation or the most recent replacement of its value .