示例#1
0
 /// <summary>
 /// 获取全部列表(Redis缓存)
 /// </summary>
 /// <returns></returns>
 public static List <Product_Class> GetListCache()
 {
     try
     {
         string key = "ProClass";
         if (RedisProvider.KeyExistSync(key))
         {
             string str = RedisProvider.StringGetSync(key);
             return(Tools.Tool.JsonHelper.Deserialize <Product_Class>(str));
         }
         else
         {
             var list = GetList();
             if (list != null && list.Count > 0)
             {
                 //缓存过期时间-1天更新一次
                 TimeSpan ts = new TimeSpan(DateTime.Now.AddDays(1).Ticks - DateTime.Now.Ticks);
                 RedisProvider.StringSetSync(key, Tools.Tool.JsonHelper.Serialize(list), ts);
             }
             return(list);
         }
     }
     catch (Exception ex)
     {
         Tools.Tool.LogHelper.WriteLog(typeof(BllProduct_Class), ex, Tools.Utility.User.GetMyMemberId(), Tools.Utility.User.GetMyMemberName());
         return(null);
     }
 }