您的位置:首页 > 其它

Cache缓存

2016-02-28 17:51 197 查看
int cacheOutTime = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["CacheOutTime"]);

List<Student> listModel = new List<Student>();

Cache cache = HttpRuntime.Cache;

string cacheItemMo = "Community";

if (cache[cacheItemMo] == null )

{

listModel = GetList();

cache.Insert(cacheItemMo, listModel, null, DateTime.Now.AddSeconds(cacheOutTime), Cache.NoSlidingExpiration);

}

else

{

listModel = cache[cacheItemMo] as List<Student>;

if (listModel == null )

{

listModel = GetList();

cache.Insert(cacheItemMo, listModel, null, DateTime.Now.AddSeconds(cacheOutTime), Cache.NoSlidingExpiration);

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: