Can DataLoader's CacheMap achieve Thread isolation or request isolation? #3046
Replies: 4 comments
-
i refer to doc it means per request should new a dataLoader... however, i think |
Beta Was this translation helpful? Give feedback.
-
I have a similar situation too. For example, in order to make |
Beta Was this translation helpful? Give feedback.
-
The fact is a DataLoader is a stateful object, even if you disregard the caches ie It has to be a stateful by design. It tracks what completable futures have been asked for per "key" and then completes them when the batch function runs. In other words it builds up state for each call to This is why it cant be a singleton - its very stateful. And then as such you cant share them between requests because of that state |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
i need to use
DataLoader
to proccess batch query, and i have some doubts as followwhy i need to use cacheMap?
why i need to achieve Thread isolation or request isolation
cacheEnable
can reduce batch process keys from each requestCacheMap
is a thread-shared instance, so i can't new aCacheMap
before query or clear Cache after queryIn addition, i wanna know what's diffence bettween
CacheMap
andValueCache
in DataLoaderam i missing something? please give me some help, thanks @bbakerman
Beta Was this translation helpful? Give feedback.
All reactions