Closed ConMur closed 3 months ago
Hi @ConMur and thanks for using FusionCache!
Sorry for the delay but I was at the MVP Global Summit and was not able to look into this. You seem to have a point: I'll look into it asap and will let you know.
Thanks!
I'm looking into this, will update soon.
In the current implementation of DistributedCacheAccessor (both Sync and Async) the only time
_events.OnMiss
fires is whenThe bug is in case 1. The code currently checks that the value returned from the
IDistributedCache
is non null and returns early if it is null. This means we never start de-serialization and therefore never call_events.OnMiss
. This leads to inaccurate distributed cache miss counters.To fix this I added
_events.OnMiss
to the if block that checks the result from theIDistributedCache
. This will cause the OnMiss event to also be triggered in the case of an exception from theIDistributedCache
. If this behavior is not desired I can update the code to only fire the event when the result from theIDistributedCache
is null.