Skip to content

expireAfterRead question #838

Answered by ben-manes
joanbalaguero asked this question in Q&A
Discussion options

You must be logged in to vote

Hi Joan,

The expiration policy maintains a single per-entry timestamp so that each operation mutates this lifetime value. In your test case there were no reads, so it did not reset the timestamp to cause it to evict earlier. The currentDuration is passed in to allow a method to return that to indicate no changes.

This generally gives the desired behavior and helps us minimize the memory overhead. If you wanted distinct policies like you described, then you could retain the multiple fields on the value yourself and return the minimum duration. Similarly if you wanted to indicate what dominant expiration was in play to indicate within the removal listener what caused the expiration event. I…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@joanbalaguero
Comment options

@joanbalaguero
Comment options

@ben-manes
Comment options

Answer selected by ben-manes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants