System.Runtime.Caching.MemoryCache 与 HttpRuntime.Cache - 有什么区别吗? [英] System.Runtime.Caching.MemoryCache vs HttpRuntime.Cache - are there any differences?

查看:30
本文介绍了System.Runtime.Caching.MemoryCache 与 HttpRuntime.Cache - 有什么区别吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道 MemoryCacheHttpRuntime.Cache 之间有什么区别,在 ASP.NET MVC 项目中首选哪一个?

据我所知,两者都是线程安全的,API乍一看或多或少相同,那么何时使用哪个有什么区别?

解决方案

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

As far as I understand, both are thread safe, API is from first sight more or less the same, so is there any difference when to use which?

解决方案

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:

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 :)

这篇关于System.Runtime.Caching.MemoryCache 与 HttpRuntime.Cache - 有什么区别吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆