Soumika
Soumika

Reputation: 65

How to implement Cache.Add and Cache.Get in .NET Core project

How to implement System.Web.HttpRuntime.Cache.Add and System.Web.HttpRuntime.Cache.Get in .NET Core project . .NET Core not supporting System.Web

Upvotes: 0

Views: 344

Answers (1)

Vijayanath Viswanathan
Vijayanath Viswanathan

Reputation: 8571

You have to use the middleware services.AddMemoryCache(); then you have to inject "IMemoryCache" to the place you want to set/get cache. With the instance of IMemoryCache you can set and get cache. Please find the documentation below,

https://learn.microsoft.com/en-us/aspnet/core/performance/caching/memory?view=aspnetcore-2.2

Upvotes: 1

Related Questions