/// <summary> /// 获取Hash中的单个key的值 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="key">Redis Key</param> /// <param name="hasFildValue">RedisValue</param> /// <returns></returns> public static T GetHashKey <T>(string key, string hasFildValue) { if (!string.IsNullOrWhiteSpace(key) && !string.IsNullOrWhiteSpace(hasFildValue)) { RedisValue value = RedisBase.HashGet(key, hasFildValue); if (!value.IsNullOrEmpty) { return(JsonConvert.DeserializeObject <T>(value)); } } return(default(T)); }
public MemberLocation Get(Guid teamId, Guid memberId) { IDatabase db = connection.GetDatabase(); var value = (string)db.HashGet(teamId.ToString(), memberId.ToString()); MemberLocation ml = MemberLocation.FromJsonString(value); return(ml); }
/// <summary> /// 在 hash 中获取值 /// </summary> /// <param name="redisKey"></param> /// <param name="hashField"></param> /// <returns></returns> public RedisValue HashGet(string redisKey, string hashField) { redisKey = GetKeyForRedis(redisKey); return(_database.HashGet(redisKey, hashField)); }