Skip to content

Is it possible to get the current weight of a cache? #822

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

You must be logged in to vote

Yes, you can use the policy api (wiki, javadoc) for these configuration-specific inspections. That is a bit hidden to not pollute the main api and keep it simpler, while also not blocking users by only offering an overly generic set of methods. Since it is a bit of a dumping ground those apis are less polished, so sorry if it could be a little nicer as it was added to as needed.

var eviction = cache.policy().eviction().orElseThrow()
long currentWeight = eviction.weightedSize().orElseThrow()

Replies: 1 comment

Comment options

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