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. When duration is zero, this method hands off to #maximumSize(long) maximumSize(0), ignoring
(long duration, TimeUnit unit)
| 629 | |
| 630 | |
| 631 | public CacheBuilder<K, V> expireAfterWrite(long duration, TimeUnit unit) { |
| 632 | checkState(expireAfterWriteNanos == UNSET_INT, |
| 633 | "expireAfterWrite was already set to %s ns", |
| 634 | expireAfterWriteNanos); |
| 635 | checkArgument(duration >= 0, "duration cannot be negative: %s %s", duration, unit); |
| 636 | this.expireAfterWriteNanos = unit.toNanos(duration); |
| 637 | return this; |
| 638 | } |
| 639 | |
| 640 | long getExpireAfterWriteNanos() { |
| 641 | return (expireAfterWriteNanos == UNSET_INT) |
no test coverage detected