Skip to content

getAll functionality in multi-threaded environment #651

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

You must be logged in to vote

Sorry, I am not fully following your problem. Can you write a unit test demonstrating the problem? Awaitility is helpful for these types of tests.

A bulk loader is allowed to not load all of the requested keys and load additional ones not requested. Whatever is loaded is cached, but only the subset of requested keys is returned to the caller. If getAll(k1) only returns k2=v2, then that entry will be cached with an empty result to the caller. If your loadAll is retrieving the wrong key then that sounds like a usage bug? Multiple loads may be in-flight at once so your loader should be thread-safe.

The faq discusses other gotchas which don't seem relevant, but may be helpful to review in cas…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@safamoha
Comment options

Answer selected by safamoha
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