Skip to content
Discussion options

You must be logged in to vote

All of Java's Set implementations use a dummy value with a Map, where Boolean.TRUE is idiomatic. The Cache.policy() can provide a best effort ordered view, such as by hot/cold or young/old. However, this is mostly for cases like persisting for a warm restart so it is meant for infrequent usage as it requires obtaining the eviction lock, meaning excessively long hold times could impact eviction. Also since it is a concurrent data structure, we are less concerned about exactness as caching is fundamentally a probabilistic problem. If you need something more precise then you might maintain a secondary data structure that is written into by your compute.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@ben-manes
Comment options

@koikahin
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