Skip to content

Is there a method to return the max capacity size? #431

Answered by tatsuya6502
shivam-880 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi. Thank you for using moka.

I wanted to see what is the max_capacity set for the cache but couldn't find any function available!

You can get it by calling cache.policy().max_capacity(). It will return Option<u64> where None means that there is no limit set.

Doesn't max_capacity represents the maximum number of entries. Isn't the cache supposed to evict older entries with the newer ones?

Yes, the cache will evict the least recently used entry (or temporary admitted entry) when the max_capacity is reached. But it will not happen immediately. The cache delays evictions to improve performance under concurrent read/write operations. It will evict a batch of entries when there are (1) eno…

Replies: 1 comment

Comment options

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