System.Runtime.Caching.MemoryCache vs HttpRuntime.Cache - are there any differences?

前端 未结 4 1784
执念已碎
执念已碎 2020-12-07 14:24

I\'m wondering if there are any differences between MemoryCache and HttpRuntime.Cache, which one is preferred in ASP.NET MVC projects?

As f

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-07 14:55

    HttpRuntime.Cache gets the Cache for the current application.

    The MemoryCache class is similar to the ASP.NET Cache class.

    The MemoryCache class has many properties and methods for accessing the cache that will be familiar to you if you have used the ASP.NET Cache class.

    The main difference between HttpRuntime.Cache and MemoryCache is that the latter has been changed to make it usable by .NET Framework applications that are not ASP.NET applications.

    For additional reading:

    • Justin Mathew Blog - Caching in .Net 4.0
    • Jon Davis Blog - Four Methods Of Simple Caching In .NET

    Update :

    According to the users feedback, sometimes Jon davis blog is not working.Hence I have put the whole article as an image.Please see that.

    Note : If it's not clear then just click on the image.After that it'll open on a browser.Then click again on it to zoom :)

提交回复
热议问题