开发者

ASP.Net Caching

开发者 https://www.devze.com 2022-12-16 09:35 出处:网络
How can we do Database driven caching开发者_如何学C in ASP.Net.Oh it is really easy.You need to Use de Cache object in ASP.NET.It is different from the Session object since th information stored in th

How can we do Database driven caching开发者_如何学C in ASP.Net.


Oh it is really easy. You need to Use de Cache object in ASP.NET. It is different from the Session object since th information stored in the Cache object is global and not per session. You can activate de Cache per Page or per Web control. I prefer per Web Control since you have a finer control over what data is cached.

If you need Database driven caching just store your business objects in the Cache object and include logic in your page in case it expires.

example

protected void Page_Load(object sender, Eventargs e){
  BusinessObject bo = Cache["SomeBO"] as BusinessObject;
  if (bo == null){
    //reload bo from database since data expired...
  }

}

check this link: http://msdn.microsoft.com/en-us/kb/kb00323290.aspx


You can use the SqlDependency or SqlCacheDependency objects.

0

精彩评论

暂无评论...
验证码 换一张
取 消