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

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

问题描述

如果有的MemoryCache HttpRuntime.Cache ,其中之一是$ P之间的差异,我想知道在ASP.NET MVC项目$ pferred?

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

据我了解,无论是线程安全的,API是从第一眼看到或多或少相同的,所以没有任何区别时所使用的?

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 得到的 缓存 为当前应用程序。

HttpRuntime.Cache gets the Cache for the current application.

的MemoryCache 类是类似于ASP.NET 缓存类。

的MemoryCache 类有访问缓存,如果你已经使用了ASP.NET 缓存<这将是你熟悉的许多属性和方法/ code>类。

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.

之间的主要区别 HttpRuntime.Cache 的MemoryCache 是,后者已被更改,使其可用通过.NET Framework应用程序是不ASP.NET应用程序。

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.

有关更多阅读:

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

更新:

根据用户的反馈,有时乔恩·戴维斯博客是不是working.Hence我已经把整篇文章为image.Please看到。

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.

注意::如果现在还不清楚,然后只要点击image.After,它会打开一个browser.Then它再次点击放大:)

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 VS HttpRuntime.Cache - 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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