English 中文(简体)
您可以在 Web 应用程序中使用 System. Runtime. Caching. MemoryCache 系统吗?
原标题:Can you use System.Runtime.Caching.MemoryCache in a web app?
  • 时间:2012-05-23 14:39:59
  •  标签:
  • asp.net
  • .net

系统. Runtime. Caching. MemoryCache 被描述为一种系统。 Web. Caching. Cache 用于非网络应用程序,但有什么区别? ASP.Net 应用程序中是否有理由不使用 System. Runtime. Caching. MemoryCache?

问题回答

我相信 System.Runtime.Caching 实际上是较新的,并且以 System.Web.Caching 为模范,区别在于您不必依赖系统。Web 组装。此外, System.Runtime.Caching.MymoryCache 是可以扩展的,而您无法继承 System.Web.Caching.Caching

我的建议是,如果你有一个共同的图书馆,例如,既用于网络也用于服务(例如),用System.Runtime.Caching 进行,这样你就不必包括系统。Web fraff(如果你不需要的话)。

有关这一专题的讨论如下:dotnet System.Web.Caching.Cache vs system.RUntime.Caching.MemoryCache

MSDN: < a href=""http://msdn.microsoft.com/en-us/library/system.runtime.caching.aspx" rel="没有跟随 nofollow norefererr" >System.Runtime.

MSDN: < a href=>"http://msdn.microsoft.com/en-us/library/system.web.caching.aspx" rel=“不跟随 norefererr" >System.Web.Caching命名空间

是的,你当然可以。

至于一个不的原因, 他们不是完全一样的事情, 不分享相同的缓存优先级, 所以如果你要使用这两个优先级, 那么在低记忆状态下, 你可能会发现的东西 被从缓存中排出 你没想到的。

如果你只使用一个或另一个, 你应该没事。

不同之处在于它被优化用于非 asp.net 应用程序, 因为它在系统. Web 上没有依赖性。 根据MSDN page , 另一个不同之处在于您可以创建多个记忆缓存类实例, 供同一应用程序和同一个 AppDomain 实例使用。

所以,真的没有理由不使用系统。Web.Caching.Cache in your asp.net application, 但是,是的, 你可以使用系统.Runtime.Caching.MemoryCache 。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签