-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] IsFailSafeEnabled required to be set true in DefaultEntryOptions #333
Comments
Hi @waynebrantley , I'm checking this, will report back soon. |
@jodydonetti any luck with this or anyway I can help? |
Hi @waynebrantley , sorry for the delay! The upcoming v2 absorbed me completely and I somehow forgot to answer you. Short VersionYes, I understood the cause of the problem. The new Longer VersionIn the code above you did everything right, you set the correct defaults and everything. But then you called Now, in FusionCache we have both Well this is true, except that - up until now - when calling
Now: as always, if no entry options are passed, the I did it this way back when I added the So, what did I do? Starting with
Of course the rest is still valid: the cache entry must be set with fail-safe enabled from the start to allow it to stick around for more, and there will still be total control over the "get" part so that, even if a cache entry has been saved with fail-safe enabled, you'll still be able to ignore it when getting it for maximum granularity. Makes sense? Btw thanks again for spotting this, I think it helped a lot in rationalizing a better, more sensible, less surprising behaviour for FusionCache. ps: I tried your MRE with the changes mentioned above applied, and it worked perfectly well. |
Hi all, v2.0.0-preview-3 is out 🥳 |
@jodydonetti Thanks so much for the detailed response. It does indeed seem that v2 will be much better. To be clear the scenario is in general (default options) I wanted fail-safe to be off, but then for certain scenarios I wanted it to be on. The main reason I need it off is the factory that creates the cache entity is using an injected object. This injected object is scoped to the http request (web app), so by the time you call the factory function the item is already disposed. I know there are several issues/topics around this issue and ways to 'work around' but essentially that is a major blocker to being able to use that. We can discuss solutions in another topic, but what comes to mind is:
|
Understood, and something pretty standard with FusionCache: you can turn it on in the
Very similar to when using EF with the normal scoped DbContext or similar, see here for more. In general the solution is to not ask for a scoped object but ask for an Hope this helps. |
Just to be super clear - was looking for the opposite of this. Turn it off in DefaultEntryOptions and turn it on for certain calls.
Understood and I can make that work, but it is not great. In our situation we use CQRS and have a decorator that does caching. The query (CQRS) is written unaware of it being cached or not (decorators for the win). With the above solution, anything decorated would have to for sure know that so it can manage the injected values differently - not injecting them - but injecting the ScopeFactory. If the factory for the cache resolved params (like |
Got it, but to be clear from my side: it's the same 👍
Agree, not an easy answer, I would need to understand more about the scenario, but I think something can be done so that it works, and I mean something good not some hacky trick. Maybe by looking at it from a different perspective. |
Hi all, I still can't believe it but v2.0.0 is finally out 🎉 |
@jodydonetti Really amazing work. So many features and all pretty simple to use.
It appears that if the DefaultEntryOptions do not turn on Fail Safe, it cannot be turned on.
This fails for the 'false' case and succeeds for the 'true' case.
Is this expected behavior
The text was updated successfully, but these errors were encountered: