Replies: 1 comment
-
Hi. Thank you for the suggestion, and sorry for the late response.
Yes, that is correct.
Right, it can be emulated with a separate set. I almost agree with you that it is a generally useful primitive. But I am not sure if we can provide a good and consistent API for this to meet all users' needs. The cache provides other methods like So, I think:
Perhaps, it would be straightforward to emulate this with a separate set at the application side? Maybe we should provide example code snippets to show how to implement it? Also, there is a technical issue if we want
An alternative way is to add another set in the cache to store keys that are being loaded by I think |
Beta Was this translation helpful? Give feedback.
-
From my experiments,
.contains_key()
returnsfalse
when a key isn't currently present but is in the process of being loaded. This can be seen with a test like the one below:I want something like
.contains_key()
, but that also returns true if the key is currently being loaded, so the following would work:This can be emulated with a separate set, but seems like a generally useful primitive.
Our use case: we have a Moka cache in front of our service, which load sheds. We don't want to load shed requests that will hit the cache, but to detect this we need something like
contains_or_is_loading_key
.Beta Was this translation helpful? Give feedback.
All reactions