Ejemplo n.º 1
0
 /// <summary>
 /// 设置新数据并返回旧数据
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="key"></param>
 /// <param name="newValue"></param>
 /// <returns></returns>
 public T GetSet <T>(string key, T newValue)
 {
     if (ContainsKey(key))
     {
         var value = _client.GetSet(key, JsonConvert.SerializeObject(newValue));
         if (!string.IsNullOrEmpty(value))
         {
             return(JsonConvert.DeserializeObject <T>(value));
         }
     }
     return(default(T));
 }