-
Notifications
You must be signed in to change notification settings - Fork 167
Closed
Description
Describe the bug
Some metrics including cache.miss, cache.set, and cache.get_or_set sometimes report incorrect values.
To Reproduce
If you call GetOrSet() with the same key 3 times, the first call results in a miss and a set event, which is correct.
The second call will result in a miss, a set (although the cache doesn't actually call to get value from user code), and a hit.
The third call will result in a hit event, which is correct.
I've written a test that shows the scenario here:
#434
Based on my debugging it seems the issue is caused by this condition
| if (ClearExpireTimestamp < 0 || (HasDistributedCache && HasBackplane == false)) |
and
ClearExpireTimestamp being -1 in the second call, which results in a secondary call to GetOrSetAsync.
Expected behavior
If you call GetOrSet() with the same key 3 times I expect to see 1 miss, 1 set, 2 hits and 4 events in total.
Versions
I've encountered this issue on:
- Latest version from
mainbranch - .NET 9.0
- Windows 10
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request