-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Ability to set CacheSettings depending on the result of the valueFactory #215
Comments
Hey @celluj34 - thanks for raising this feature request! Sounds like a perfectly reasonable idea - currently I propagate the exception because I didn't like the idea of swallowing by default however having some mechanism to selectively skip that would be pretty useful. I've got an idea of how I might be able to do something to support this with a fluent-like API which might be an easier path forward than passing control to within the value factory itself but either way, being able to opt-out of exceptions being bubbled up is a useful feature to have. |
Another thought I had, what about adding an overload for the |
Sorry hit the wrong button! |
+1 on this for caching Authentication (bearer) tokens which have their expiration time coming on the object that returns from auth endpoints. It would be something like this (I tried rolling out my own methods of Redis Caching, using RedLock for synchronization between Redis Nodes, not sure if it would work):
|
What problem does the feature solve?
I would like to be able to set the
CacheSettings
depending on the result of some logic that's run in thevalueFactory
of theGetOrSetAsync
method. This would function similarly to theIMemoryCache.GetOrCreateAsync
provided by Microsoft.The reason this is important to me is, when an exception is thrown, or some logic fails inside the
valueFactory
, I want the data to not be cached.How would you use/interact with the feature? (if applicable)
How would you call it in your own code?
See code sample above
Are there constraints that would need to be in place with this feature?
None that can think of - it may be a breaking change, or change how the stacks work.
If I misunderstand how I'm supposed to use this, please let me know. We only do it this way because of some bugs we had where the
valueFactory
s were being run more than once when the database methods threw an exception.The text was updated successfully, but these errors were encountered: