Open joakimriedel opened 4 years ago
Yeah this seems like a very sensible suggestion for a v3+ release. Would be best to have done the benchmarking beforehand so we can compare the resulting number of allocations between both versions to ensure it is better, but seems very likely that it will be.
I'm assuming we'd have to migrate off of the Microsoft.Caching.Extensions namespace (https://source.dot.net/#Microsoft.Extensions.Caching.Abstractions/MemoryCacheExtensions.cs,105) and recreate this as ValueTask?
[Use the Thumbs Up reaction to vote for this feature, and please avoid adding comments like "+1" as they create noise for others watching the issue.]
I'm looking for a library to cache values at certain hot paths in my code.
Browsing through your API, I see that the async methods are returning
Task
and notValueTask
. The latter would be preferred since most of the requests would be cached and could be returned asT
and not require the overhead of generating an actualTask<T>
object.Enhancement is to change
GetAsync<T>
,GetOrAddAsync<T>
to returnValueTask<T>
, but would require changing code all the way down to whereT
is actually returned in the providers to supportValueTask<T>
. Perhaps for 3.0?