[Feature] "onCacheMiss"
Closed this issue · 2 comments
I haven't yet run into this case myself but I might in the future. I noticed the API supports "onCacheHit" and thought it could also be helpful to have an "onCacheMiss" for testing/development reasons at the very least. I can't think of a production-grade use-case of this otherwise yet. My reasoning is that for performance fine-tuning it could be good to be able to set things up with the callback so you can be notified when you miss the cache, so you'd be more likely to address your use of moize.
EDIT: Would it otherwise be sufficient to just use "onCacheAdd" for this kind of thing too?
You are on the nose in that onCacheAdd
would be the way to accomplish what you are talking about. onCacheHit
is specifically called when a matching entry exists in cache, whereas onCacheAdd
is called when a new entry is added (aka "missed" in cache). There is not a scenario where both is called.
The reason for the "Add" naming convention is to convey that it was not in cache but now is, whereas "Miss" would only give the impression of the former and is ambiguous about the latter. The concepts, though, are interchangeable.
@planttheidea Ahh okay, I had a feeling that might be sufficient but I wasn't sure. Thank you for your reply. I will close this issue 🙂