So I need to access in bulk many different hashes (in StackExchange.Redis, I have different RedisKey's).
What is the best (fastest) way to do it? For example, for these two possible implementations, is either correct? Which one works better?
1.
List<Task<HashEntry[]>> list = new List<Task<HashEntry[]>>();
List<RedisKey> keys; //Previously initialized list of keys
foreach (var key in keys)
{
var task = db.HashGetAllAsync(key);
list.Add(task);
}
await Task.WhenAll(list);
List<Task<HashEntry[]>> list = new List<Task<HashEntry[]>>();
List<RedisKey> keys; //Previously initialized list of keys
IBatch batch = db.CreateBatch();
foreach (var key in keys)
{
var task = batch.HashGetAllAsync(key);
list.Add(task);
}
batch.Execute();