You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature Request] Allow factory method of hybrid cache to return result AND HybridCacheEntryOptions. #6142
When using HybridCache, there are cases where you may not know in advance if or how long a value should be cached:
Discarding a Cached Value
You retrieve a value, but the result turns out to be invalid and shouldn't be cached at all. While you could throw an exception in the factory, this is costly. Returning null isn't a solution either, as null would simply get cached.
Conditional Cache Durations
Some values inherently know how long they should remain cached. For example, when retrieving access tokens, the token itself determines its validity period, but the client may not be aware of this.
Possible solutions
One approach is to allow the factory to return a tuple containing both the result (if any) and cache options. In these cache options, you can then decide not to store any result.
Alternatively, if you only need to handle scenario #1, you can simply avoid caching null results.
changed the title [-][Feature Request] Allow factory method of hybrid cache to control / set HybridCacheEntryOptions.[/-][+][Feature Request] Allow factory method of hybrid cache to return result AND HybridCacheEntryOptions.[/+]on Mar 18, 2025
Activity
[-][Feature Request] Allow factory method of hybrid cache to control / set HybridCacheEntryOptions.[/-][+][Feature Request] Allow factory method of hybrid cache to return result AND HybridCacheEntryOptions.[/+]Erwinvandervalk commentedon Mar 18, 2025
sorry, looks like a duplicate of: dotnet/runtime#129842