dotnet / dotnet/extensions

[HybridCache] [Behavior Proposal] Allow Options from GetOrCreateAsync to not set "null" in cache

Open
#7,664 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
3.2k
Forks
894
Avg merge
1d 12h
Merged PRs (30d)
23

Description

Hello,

As far as I've tested, it seems that when a CACHE MISS happen the "Create Factory" is called.
When this happen and the factory also returns `null` (like for example `db.FirstOrDefault(id)`, then the `null` value is also propagated to the cache.

This create quite some noise for cached object lifetime managment.

It would be nice to be able to pass a value inside the already existing `Options` parameter of the `GetOrCreateAsync` that tells the factory:
"If the factory returns `null`, don't bother settings `null` in cache"

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.