Skip to content

[Caching] remove one additional interface call and a branch#1603

Merged
sebastienros merged 1 commit intoaspnet:masterfrom
adamsitnik:cachePerf
Nov 19, 2020
Merged

[Caching] remove one additional interface call and a branch#1603
sebastienros merged 1 commit intoaspnet:masterfrom
adamsitnik:cachePerf

Conversation

@adamsitnik
Copy link
Contributor

This is a very tiny improvement that gives... +1-2k RPS

The Get<T> method is an extension method that uses IMemoryCache interface:

https://github.com/dotnet/runtime/blob/69d61271f900afd7ae6dea7f0c5e57d43090f9dd/src/libraries/Microsoft.Extensions.Caching.Abstractions/src/MemoryCacheExtensions.cs#L18-L21

By using MemoryCache.TryGetValue instead, we remove one interface method invocation and a branch

@adamsitnik
Copy link
Contributor Author

@sebastienros ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants