日期:2014-05-16 浏览次数:20481 次
string key = "test";
test t1 = new test();
t1.id = DateTime.Now.Second;
test t2 = new test();
t2.id = t1.id;
string str = Request.PhysicalApplicationPath + @"html/Blog_Home.html";
//创建缓存依赖项
test tt = HttpContext.Current.Cache[key] as test;
if (tt == null)
{
CacheDependency dependency = new CacheDependency(str);
HttpContext.Current.Cache.Insert(key, t1, dependency, Cache.NoAbsoluteExpiration, new TimeSpan(0, 30, 0));
}
tt = HttpContext.Current.Cache[key] as test;
Response.Write(tt.id + "</br>");
t1.id = DateTime.Now.Second+10;//看这里
tt = HttpContext.Current.Cache[key] as test;
Response.Write(tt.id + "</br>");