-
Hi, I onboarded Caffeine 2.8 a few months ago to add an in-process cache to our service. I implemented both load and loadAll for this cache, with corresponding calls to our database. A separate thread is created for each incoming request to our service. This request is identified via a unique requestId. Implementations of the object cache loader (the classes that implement load and loadAll methods) are called by an ObjectCacheManager class which contains either the get or getAll call. We have added log statements in both the cache loader and ObjectCacheManager classes. Objects in cache are keyed based on database primary key. What we are seeing occasionally is this: Based off of my understanding of loadAll / getAll, request A is returning no output because the key from the loadAll request is different from the input key to getAll. Is this correct? However, I still am unsure of why request B is interfering with request A. This is only happening for our getAll/loadAll requests. The cache is performing as expected when loading single objects. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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 The faq discusses other gotchas which don't seem relevant, but may be helpful to review in case its helpful. |
Beta Was this translation helpful? Give feedback.
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…