/// <summary> /// 根据Key数组从Redis读取 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="keys"></param> /// <returns></returns> public IDictionary<string, T> GetProtobuf<T>(List<string> keys) where T : class { var redisKeys = new RedisKey[keys.Count]; for (var i = 0; i < keys.Count; i++) { redisKeys[i] = keys[i]; } var values = this.client.StringGet(redisKeys); var dic = new Dictionary<string, T>(); for (var i = 0; i < values.Length; i++) { var value = values[i]; dic[redisKeys[i]] = value.IsNullOrEmpty ? default(T) : ProtoBufExtensions.DeserializeProtoBuf<T>(values[i]); } return dic; }
/// <summary> /// 从Redis读取 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="key"></param> /// <returns></returns> public T GetProtobug<T>(string key) where T : class { var value = this.client.StringGet(key); return value.IsNullOrEmpty ? default(T) : ProtoBufExtensions.DeserializeProtoBuf<T>(value); }