开发者

ASP.net - How to put a recordset in cache

I have around 100 rows in database ( which can increase in future ) for different labels used in page. Thes开发者_如何学Goe rows are required on all pages. I want to do it in a way that I get these rows once from db and put some where in cache or something similar to that. So that i don't have to query database on every page refresh. And how can this cache be used by all site visitors?


You can use Cache Variables something like this :

Cache["COMMON_DATA"] = lstData (This can be any collection like LIST<Country>)

You can also use SqlCacheDependency in asp.net that will auto reset your cache if more rows are added in the the database

else you can update the Cache again manually after inserting data in the table


Caching in ASP.net and Application State would be a couple of ideas for you.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜