Is it possible to avoid caching a value altogether when using adaptive caching ? #572
-
|
I'm looking for a way to avoid caching a value when using the adaptive caching pattern. What I would like to do is represented by the following snippet: Notice that in the What is the best way to achieve this with Fusion Cache ? I can think of some alternatives:
Is there any better approach to solve this problem ? I noticed that on the Thanks for helping. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
|
Set |
Beta Was this translation helpful? Give feedback.
-
Yes, as mentioned by @anntnzrb (thanks!) you can use the 2 "skip write" options.
Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks @jodydonetti and @anntnzrb for the help with this topic. Do you think it is valuable to document this pattern ? If it is, I can maybe propose a pull request to add a note about this to the docs. |
Beta Was this translation helpful? Give feedback.

Set
ctx.Options.SkipMemoryCacheWrite = trueandctx.Options.SkipDistributedCacheWrite = truein your else branch. This skips caching at both L1 and L2 levels without writing anything. Better thanDuration = TimeSpan.Zerowhich still writes (then expires). See/src/ZiggyCreatures.FusionCache/FusionCacheEntryOptions.cs:409-422.