/// <summary> /// 读取Key/Value值 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="key"></param> /// <returns></returns> string KGetString(string key, out bool find) { find = false; var str = new StackExchangeRedisHelper(_id).Get(key); find = str != null; return(str); }
public List <string> HGetAllKeys(string hashId) { var allKeys = new StackExchangeRedisHelper(_id).GetDatabase().HashKeys(hashId); if (allKeys.Length == 0) { return(new List <string>()); } return(allKeys.Select(b => b.ToString()).ToList()); }
/// <summary> /// 递增 /// </summary> /// <param name="key"></param> /// <param name="type"></param> /// <param name="timeOut"></param> /// <returns></returns> public long Increment(string key, string type, TimeSpan timeOut, int num = 1) { key = string.Format("Increment_{0}", key); var exis = ContainsKey(key); var result = new StackExchangeRedisHelper(_id).GetDatabase().HashIncrement(key, type, num); if (!exis) { //自动失效,清理垃圾数据 KSetEntryIn(key, timeOut); } return(result); }