Closed demorgi closed 10 months ago
Hi @demorgi and thanks for using FusionCache!
What you are looking for is Adaptive Caching: just before returning the value in the factory check if it is null: in that case set the Duration
to TimeSpan.Zero
and it will not be cached.
Hope this helps.
Problem
At the moment it is possible to cache
null
as a value for the key, sometimes it's better to run a factory each time for a null value to make sure we would receive a value as soon as it's available.Solution
It would be great to have a configuration\strategy to make a choice to disable null caching
Alternatives
This can be achieved by building a wrapper(decorator) around the fusion cache on the consumer side but seems a little bit excessive