简体   繁体   English

asp.net中有几种类型的缓存

[英]How many types of Cache is there in asp.net

asp.net中有几种类型的缓存,如何实现?

There is 1 Cache object, that you can use more or less like the Application object 有1个Cache对象,您可以像Application对象一样使用或多或少

And there is Output caching, per page or per user control. 每个页面或每个用户控件都有输出缓存。

You would use the Cache object like this (there are overloads): 您将使用Cache对象,如下所示(有重载):

Cache.Insert("myKey", myValue,  null, DateTime.Now.AddMinutes(2),
   System.Web.Caching.Cache.NoSlidingExpiration);

And for outputcaching, you can use this line below the <%@ Page %> line: 对于输出缓存,可以在<%@ Page %>行下面使用此行:

 <%@ OutputCache Duration="120" VaryByParam="myParam"%>

您可以使用企业库中的CacheManager http://msdn.microsoft.com/zh-cn/library/cc467894.aspx ,或者如果您想要分布式缓存,则可以使用Memcached http://memcached.org/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM