Skip to content
Discussion options

You must be logged in to vote

The cache uses heap memory by layering on top of ConcurrentHashMap. It wraps the value to capture additional per-entry metadata, like the expiration timestamp, and holds a few per cache instance data structures (like the frequency histogram). The metadata overhead is fairly inexpensive and a rough evaluation is captured on the wiki.

As you said, a weigher lets you calculate the cost of the key/value pair. That's actually quite tricky on the JVM (see JEP-8249196) so we don't provide an explicit strategy. You can use java object layout, jamm, etc for a rough estimate.

Typically to understand the tradeoff of how large the cache should be requires analyzing the hit rate curve to decide when y…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@Snelly2458
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