Home > Software engineering >  What is the difference between Microsoft.Extensions.Caching and System.Runtime.Caching?
What is the difference between Microsoft.Extensions.Caching and System.Runtime.Caching?

Time:10-14

There are two packages for In-Memory Caching:

  • Microsoft.Extensions.Caching
  • System.Runtime.Caching

Which one is the most efficient for the WPF .NET Framework?

CodePudding user response:

It depends on what framework you are using WPF on.

If using .NET Framework 4.6.0 or below, you won't be able to use the features of .NET Standard 2.0 as it targets .NET Standard 1.3.

In that case, use System.Runtime.Caching.

If not, then you will be targeting .NET Standard 2.0 with any version of .NET Framework starting 4.6.1 & any version of .NET Core from 2.0 and onwards.

In these scenarios, use Microsoft.Extensions.Caching.Memory as it's recommended over System.Runtime.Caching in all other circumstances:

Use System.Runtime.Caching/MemoryCache as a compatibility bridge when porting code from ASP.NET 4.x to ASP.NET Core.

  • Related