Tuesday, February 09, 2010

CacheManager in enterprise library 4.1

I worked around how to get familiar with Microsoft's Enterprise Library 4.1 Cache Manager.
GetCacheManager method of CacheFactory will retrieve the data from the Cached pool of data.



CacheManager cm = CacheFactory.GetCacheManager("Cache Manager");
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("Students.xml"));
cm.Add("CachedDataSet", ds.Tables[0]);
DataTable dt = (DataTable)cm.GetData("CachedDataSet");
foreach (DataRow row in dt.Rows)
{
Response.Write(row[0].ToString());
}



Place the following line between or use the Enterprise Library 4.1 GUI to generate config setting for your web.config file.




Following code goes between tag