Is there a reason getAll() does not lock the data loading like the getOne()? #613
-
Is there a reason getAll() does not lock and multiple concurrent requests can trigger expensive bulkLoad at the same time? By default, was expecting com.github.benmanes.caffeine.cache.LocalManualCache#getAll to lock on a concatenated String of sorted keys, or the first key in the collection or may be even pass a custom key/lock builder as part of the cache may be? The only other option is to write our own wrapper on top of LoadingCache to delegate all but some expensive methods like getAll(). It would be nice to add a lockBuilder() from the collection of keys or even lock on a custom key to be loaded? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
This is discussed in the FAQ. Does that help? A blocking bulk load is supported by |
Beta Was this translation helpful? Give feedback.
This is discussed in the FAQ. Does that help?
A blocking bulk load is supported by
AsyncCache
because it can insert an in-flight entry immediately. Unfortunately for a synchronous this is not possible, as we lock throughConcurrentHashMap
which does not allow a caller to compute multiple entries at once. Usually the async cache is a good fit since expensive calls can mean remote calls so per-entry futures fits the mental model.