是System.Web.Caching或System.Runtime.Caching preferable一个.NET 4的Web应用程序 [英] Is System.Web.Caching or System.Runtime.Caching preferable for a .NET 4 web application

查看:245
本文介绍了是System.Web.Caching或System.Runtime.Caching preferable一个.NET 4的Web应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加缓存来一个ASP.NET Web应用程序。这是.NET 4中,这样我就可以在System.Runtime.Caching命名空间(其中,按照我的理解,加入对在System.Web.Caching发现提供类似的功能使用的类,但对于非Web的应用程序。)

I am adding caching to an ASP.NET web application. This is .NET 4, so I can use the classes in the System.Runtime.Caching namespace (which, as I understand it, was added to provide similar functionality to that found in System.Web.Caching, but for non-Web-apps.)

但由于这的的一个web应用程序,我是不是最好使用System.Web.Caching?或者是在某些方面较新的System.Runtime.Caching更胜一筹?

But since this is a web app, am I better off using System.Web.Caching? Or is the newer System.Runtime.Caching superior in some way?

推荐答案

微软建议使用System.Runtime.Caching所有缓存目的。看到这一点:<一href=\"http://msdn.microsoft.com/en-us/library/dd997357.aspx\">http://msdn.microsoft.com/en-us/library/dd997357.aspx

Microsoft recommends using System.Runtime.Caching for all caching purposes. See this: http://msdn.microsoft.com/en-us/library/dd997357.aspx

虽然,我所遇到的人们正与MemoryCache.Default实例发出一对夫妇线程。一段时间后,它停止工作正常。您使用Add或set方法的任何项目实际上并没有被添加到缓存中。我想同样的,并能够重现此问题与显式调用MemoryCache.Default.Dispose()方法。

Although, I have come across a couple threads where people are having issues with the MemoryCache.Default instance. After a while, it stops working properly. Any item you add using the Add or Set method does not actually get added to the cache. I tried the same and was able to reproduce this issue with explicitly calling MemoryCache.Default.Dispose() method.

下面是链接:
<一href=\"http://stackoverflow.com/questions/7422859/memorycache-disposed-in-web-application\">MemoryCache配置在Web应用程序中

http://forums.asp.net/t/1736572.aspx/1

我的建议是使用System.Web.Caching(HttpContext.Current.Cache)

My recommendation is to use the System.Web.Caching (HttpContext.Current.Cache)

更新:

此问题已得到修复的MS。请在下面后接受的答案:
运行缓存解决的问题

This issue has been fixed by MS. Check the accepted answer in the post below: Runtime Cache Issue Resolved

这篇关于是System.Web.Caching或System.Runtime.Caching preferable一个.NET 4的Web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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