Пример #1
0
 public static bool SetUpdate(string key, string guid, string value)
 {
     lock (lockObj)
     {
         bool b = false;
         try
         {
             List <object> list = RedisReadExHelper.SetSearch(key, 0, "\"GUID\":\"" + guid + "\"", 1000000);
             if (list.Count > 0)
             {
                 //var result = RedisWriteHelper.SetRemoveAsync(key, value);
                 b = RedisWriteHelper.SetRemove(key, list[0].ToString());
                 ///Task<bool>  result = RedisWriteHelper.SetRemoveAsync(key, list[0].ToString());
                 if (b)
                 {
                     var isSuccess = RedisWriteHelper.SetAdd(key, value);
                     b = isSuccess;
                 }
             }
             else
             {
                 var isSuccess = RedisWriteHelper.SetAdd(key, value);
                 b = isSuccess;
             }
         }
         catch (Exception ex)
         {
             //LogHelper.ErrorLog(string.Format("SetUpdate失败,key:{0},guid:{1},错误信息:{2}", key, guid, ex.ToString()));
         }
         return(b);
     }
 }
Пример #2
0
 public static bool SetRemove(string key, string guid)
 {
     lock (lockObj)
     {
         bool b = false;
         try
         {
             List <object> list = RedisReadExHelper.SetSearch(key, 0, "\"GUID\":\"" + guid + "\"", 1000000);
             if (list.Count > 0)
             {
                 var result = RedisWriteHelper.SetRemoveAsync(key, list[0].ToString());
                 b = result.Result;
             }
         }
         catch (Exception ex)
         {
             //LogHelper.ErrorLog(string.Format("SetRemoveAsync失败,key:{0},guid:{1},错误信息:{2}", key, guid, ex.ToString()));
         }
         return(b);
     }
 }