How can we do Database driven caching in ASP.Net.
-
2What does 'database driven caching' mean? You want to cache items that are normally fetched from the database?HS.– HS.2010-01-13 04:33:59 +00:00Commented Jan 13, 2010 at 4:33
-
Possible duplicate: stackoverflow.com/q/7312551/2291Jon Adams– Jon Adams2011-10-20 02:25:55 +00:00Commented Oct 20, 2011 at 2:25
-
Possible duplicate: stackoverflow.com/q/1286456/2291Jon Adams– Jon Adams2011-10-20 02:35:29 +00:00Commented Oct 20, 2011 at 2:35
Add a comment
|
2 Answers
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