Specifies that each entry should be automatically removed from the cache once a fixed duration has elapsed after the entry's creation, the most recent replacement of its value, or its last access. Access time is reset by all cache read and write operations (including {@code Cache.asMap().get(Object)
(long duration, TimeUnit unit)
| 668 | |
| 669 | |
| 670 | public CacheBuilder<K, V> expireAfterAccess(long duration, TimeUnit unit) { |
| 671 | checkState(expireAfterAccessNanos == UNSET_INT, |
| 672 | "expireAfterAccess was already set to %s ns", |
| 673 | expireAfterAccessNanos); |
| 674 | checkArgument(duration >= 0, "duration cannot be negative: %s %s", duration, unit); |
| 675 | this.expireAfterAccessNanos = unit.toNanos(duration); |
| 676 | return this; |
| 677 | } |
| 678 | |
| 679 | long getExpireAfterAccessNanos() { |
| 680 | return (expireAfterAccessNanos == UNSET_INT) |
no test coverage detected