public static GetDictionaryResult <T> GetAllPropperAsDictionary <T>(this StackExchangeRedisCacheClient cacheClient, IEnumerable <string> keys)
            where T : class
        {
            var keysList = keys.ToList();

            if (!keysList.Any())
            {
                return(new GetDictionaryResult <T>(null, keysList));
            }

            var redisKeyArray    = new RedisKey[keysList.Count];
            var redisResultArray = (RedisResult[])cacheClient.Database.ScriptEvaluate(CreateLuaScriptForMget(redisKeyArray, keysList), redisKeyArray);
            var result           = new GetDictionaryResult <T>();

            for (var index = 0; index < redisResultArray.Length; ++index)
            {
                if (!redisResultArray[index].IsNull)
                {
                    var obj = cacheClient.Serializer.Deserialize <T>((byte[])redisResultArray[index]);
                    result.Add(keysList[index], obj);
                }
                else
                {
                    result.AddMissing(keysList[index]);
                }
            }

            return(result);
        }
Example #2
0
 public GetDictionaryResult <T> Add(GetDictionaryResult <T> other)
 {
     if (other == null)
     {
         return(this);
     }
     return(this.AddRange((IDictionary <string, T>)other.Data).AddMissingRange((IList <string>)other.MissingKeys));
 }