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);
}
}
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);
}
}
相关文章推荐
- JSON对象和string的相互转换
- ffmpeg 学习资料
- java程序的运行过程
- 10.Android UiAutomator Junit 断言函数的使用
- Linux 常用命令3-- 目录操作rmdir 和 rm
- Android 系统稳定性 - ANR(一)
- poj 3630 找重复前缀 trie树
- HashMap的实现原理
- 收集的48个Shell脚本小技巧
- List转树形数据,供tree使用
- 104.Reverse Words in a String
- 实践学习——台湾行
- 购买计划
- Java泛型实例
- 详解Javascript中的Object对象
- Android 中的 Service 全面总结
- matlab-code folding功能 将某些行的代码折叠起来方便查看
- Android官方API文档目录
- MyEclipse使用依赖项目在发布项目时报ClassNotFound
- Android中获得正在运行的程序和系统服务的方法