奇怪,泛型不能cache缓存吗??
//infoModel是实体类
List<infoModel> myList = null;
//读取各分类下面资讯
if (Cache["exhiCategroyInfo"] == null)
{
myList = new info().getInfoIndexTopInfo();
if (myList != null)
{
//缓存委托
CacheItemRemovedCallback callBack = new CacheItemRemovedCallback(onCategroyInfoRemove);
//缓存时间(秒)
new dbCache().insertCache("exhiCategroyInfo", myList, 3000, callBack);
}
}
else
{
myList = (List<infoModel>)Cache["exhiCategroyInfo"];
}
private void onCategroyInfoRemove(string key, object value, CacheItemRemovedReason reason)
{
//create an instance of the callback delegate
CacheItemRemovedCallback callBack =
new CacheItemRemovedCallback(onCategroyInfoRemove);
new dbCache().insertCache(key, value, 3000, callBack);
}
//insertCache
public void insertCache(string cacheKey, object cacheValue, int cacheTime, CacheItemRemovedCallback callBack)
{
//判断缓存是否存在
if (!checkCacheKeyIsExist(cacheKey))
{
Cache _cache = HttpRuntime.Cache;
_cache.Insert(cacheKey, cacheValue, null, System.DateTime.Now.AddSeconds((double)cacheTime), Cache.NoSlidingExpiration, CacheItemPriority.Default, callBack);
}
else
HttpContext.Current.Response.Write("抱歉,该名称的缓存已存在!");
}
//我调试了,确认数据已经被缓存;当我重新刷新页面,缓存竟然为空,为什么呢??
List<infoModel> myList = null;
//读取各分类下面资讯
if (Cache["exhiCategroyInfo"] == null)
{
myList = new info().getInfoIndexTopInfo();
if (myList != null)
{
//缓存委托
CacheItemRemovedCallback callBack = new CacheItemRemovedCallback(onCategroyInfoRemove);
//缓存时间(秒)
new dbCache().insertCache("exhiCategroyInfo", myList, 3000, callBack);
}
}
else
{
myList = (List<infoModel>)Cache["exhiCategroyInfo"];
}
private void onCategroyInfoRemove(string key, object value, CacheItemRemovedReason reason)
{
//create an instance of the callback delegate
CacheItemRemovedCallback callBack =
new CacheItemRemovedCallback(onCategroyInfoRemove);
new dbCache().insertCache(key, value, 3000, callBack);
}
//insertCache
public void insertCache(string cacheKey, object cacheValue, int cacheTime, CacheItemRemovedCallback callBack)
{
//判断缓存是否存在
if (!checkCacheKeyIsExist(cacheKey))
{
Cache _cache = HttpRuntime.Cache;
_cache.Insert(cacheKey, cacheValue, null, System.DateTime.Now.AddSeconds((double)cacheTime), Cache.NoSlidingExpiration, CacheItemPriority.Default, callBack);
}
else
HttpContext.Current.Response.Write("抱歉,该名称的缓存已存在!");
}
//我调试了,确认数据已经被缓存;当我重新刷新页面,缓存竟然为空,为什么呢??
...全文
相关推荐
android-cache-fix-gradle-plugin:Gradle插件来修复Android缓存问题
android-cache-fix-gradle-plugin:Gradle插件来修复Android缓存问题
【嵌入式】程序为什么越优化越慢?
对于一个看似毫无规律可寻的问题,有时解决之道可能就蕴藏在问题本身,先不去考虑问题的表象为什么没有规律,在一个嵌入式平台里,能让程序运行时间不可测的家伙,最大的嫌疑可能就是cache了。
SQLDependency 使用解說 - 1
針對 ADO.NET 中的 SQLDependency 使用解說
cuda-optimization-tips-tricks-and-techniques.pdf
NVIDIA CUDA使用优化技巧指南《cuda-optimization-tips-tricks-and-techniques》。
一年计算机一级MSOffice专家命题试卷分析.pdf
一年计算机一级MSOffice专家命题试卷分析.pdf


