Closed F2 closed 3 months ago
Hi @F2 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. Anyway interesting, you seem to be right at first glance: now that I'm back I'll look into this asap and will let you know.
Thanks!
I'm looking into this, will update soon.
Update: ok I think I've found the culprit, working on the best way to make the change considering all the edge cases.
Hi @F2 , here's an update: I've made some changes and I can confirm it now works as intended! I also added some tests to make sure it's strictly verified from now on to avoid any future regressions.
Will push the new version soon and I'll update you when that happen.
Thanks again!
Hi, I just release v1.1.0 🥳
@jodydonetti Thank you so much. I can confirm it works in my code. 🤩
First of all, thank you for this library! The best .NET caching library out there. 👍
Describe the bug
According to the Options docs, the field
FailSafeMaxDuration
is the amount of time a cached entry will be available when using fail-safe.This is also backed by the FailSafe docs. That example describes a
Duration
of 5 minutes, aFailSafeMaxDuration
of 2 hours, and aFailSafeThrottleDuration
of 1 minute, and concludes:However, using the same example with smaller durations (see below), it seems that the cache is never deleted when the factory consistently fails.
To Reproduce
Here's a MRE (Minimal Reproducible Example) of the issue:
Expected behavior
It should not be possible to get the value after 10 seconds. It should throw an exception.
Actual behavior
It keeps getting the value for forever.![image](https://github.com/ZiggyCreatures/FusionCache/assets/916098/5b6a71c9-1e5e-4573-80ae-82572901184e)
Note, setting
FailSafeThrottleDuration
to a super high value makes it behave slightly better. In my example, it would throw an exception after 15 seconds. Still, according to documentation, it should happen after 10 seconds. And besides, using a throttle is a good idea.Versions
I've encountered this issue on:
Additional information
As an aside, in the FailSafe docs it says:
FailSafeMaxDuration
: how long a value should be kept around at most, after its logical expirationThat makes it sound like if
Duration
is 5 seconds andFailSafeMaxDuration
is 10 seconds, the total time the value would be kept around is 5+10 seconds. But that's inconsistent with the rest of the docs, including some of your answers, stating it will take the highest value of the two.