public IEnumerable <CalculatedElementData> LRange <T>(string key) { //LRANGE int chunk_size = 1000; Log.Information($"Get costattribute list, begin"); var length = cacheClient.Db0.Database.ListLength("list_key"); int chunk_count = (int)Math.Floor((decimal)length / chunk_size); var partitoner = Partitioner.Create(0, length, chunk_size); RedisValue[] bag = new RedisValue[length]; Parallel.ForEach(partitoner, new ParallelOptions() { MaxDegreeOfParallelism = 4 }, value => { cacheClient.Db0.Database.ListRange("list_key", value.Item1, value.Item2).CopyTo(bag, value.Item1); }); var result = bag.Select(c => serializer.Deserialize <CalculatedElementData>(c)).ToList(); //for (int i = 0; i < chunk_count; i++) //{ // var chunk_length = (i == chunk_count) ? (length % chunk_size) : chunk_size; // var result = await _redisService.LRangeAsync<CalculatedElementData>("list_key", i * chunk_size, (i + 1) * chunk_size - 1); //} return(result); }