第一步:判断读取缓存数据

#region 缓存读取
            if (HttpRuntime.Cache["App"] != null)
            {
                return HttpRuntime.Cache["App"];
            }
#endregion

第二步:缓存失效时重新设置缓存

#region 设置缓存
                if (HttpRuntime.Cache["App"] == null)
                {
                    //缓存当前数据
                    HttpRuntime.Cache.Add("App", new { UserInfo, UserDefaultResumeInfo, InviteList = listdic }, null, DateTime.UtcNow.AddSeconds(30), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Default, null);//设置30秒有效缓存
                }
                #endregion

 

相关文章:

  • 2022-12-23
  • 2022-02-10
  • 2022-12-23
  • 2022-12-23
  • 2021-11-15
  • 2021-08-09
猜你喜欢
  • 2022-01-24
  • 2022-12-23
  • 2022-12-23
  • 2021-07-28
  • 2022-12-23
  • 2022-01-30
  • 2021-09-17
相关资源
相似解决方案