有关缓存的思考

string strDate = DateTime.Now.ToString("yyyyMMdd") + context.Session["staffId"].ToString() + "branchHeader";
if (context.Cache[strDate] != null)
{
context.Response.Write(context.Cache[strDate].ToString());
}
else
{
string outString = GetChartHeader(quarter);
context.Cache.Insert(strDate, outString, null, DateTime.Now.AddHours(2), TimeSpan.Zero);
context.Response.Write(GetChartHeader(quarter));
}

  

posted @ 2012-06-05 15:33  wx_xfy6369  阅读(144)  评论(0编辑  收藏  举报