Skip to content

Caffeine cache instance size calculation #901

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

You must be logged in to vote

I am unsure how your cache is configured, but the cache is allowed to exceed the maximum size by a modest amount to allow for improved concurrency.

Internally the cache uses a write buffer to enque pending operations that need to be replayed against the eviction policy. This avoids having all writing threads block and run sequentially, which would be the common case once the cache is full. Instead, after the map operation the policy work is handed off and scheduled to be processed immediately. A typical cache would synchronize all writes and cause lock contention, even though the work to maintain LRU is inexpensive. In this model a batch of work can be applied and writes to distinct keys …

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