Skip to content

caffeine lock issue for using get with mappingFunction #605

Discussion options

You must be logged in to vote

Most of the time this isn't a problem because the number of reads is much higher than writes. This library's focus on an excellent hit rate means fewer misses and therefore fewer loads. Since the map will evenly distribute entries there is also a good amount of inherent write concurrency. If profiling your application does indicate a bottleneck then there are two very simple approaches that can fix the problem.

  1. The number of bins increases with the hash table's size, so a larger map will have a higher write concurrency level. A small map with a high write rate can set a larger initialCapacity to increase the number of bins. The implementation docs of the map state,

Lock contention prob…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@PatrickZhangOracle
Comment options

@ben-manes
Comment options

@PatrickZhangOracle
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