Skip to content

Blocking behavior on expired entry with a synchronous load? #800

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

You must be logged in to vote

I'll try to watch this evening (morning my time, so meeting hours). In both caches, a get(key) that loads a missing entry will block all threads requesting that key, with only one thread performing the work. Whereas Guava wrote a custom hashmap to support this, Caffeine is able to leverage Java 8's compute methods (e.g. computeIfAbsent). An entry that expired is not usable, so it forces the cache to treat the lookup as a miss. All of this is to avoid a cache stampede which can cause can cause performance degradations and outages.

Expiration is a hard edge, so popular items that expire can cause periodic latency spikes as threads block waiting for the cache load. This latency can be hidden…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@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