62,046
社区成员
发帖
与我相关
我的任务
分享
public static void GetOrInsertCache(string key, object value, double cacheTime)
{
//判断key值对应的缓存存在否
if (HttpRuntime.Cache.Get(key) == null)
{
//写入缓存,唯一标识key值,缓存内容value,缓存失效时间cachetime(我这里用的是小时)
HttpRuntime.Cache.Insert(key, value, null, DateTime.Now.AddHours(cacheTime), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.Default, null);
}
else
{
//得到缓存数据
string GetCacheValue=HttpRuntime.Cache.Get(key);
}
}
在url中可以传入吗? 用法感觉和cookie 和session差不多
用法感觉和cookie 和session差不多
1.是的 2.获取与该页驻留的应用程序关联的Cache对象。 3.你可以传一个Cache的 key过去,然后去获取Cache