1

I am trying to get multiple set at the same time by keys. I am using the Basic tier of Azure Redis, with latest Stackexchange.Redis (1.1.608)

Here is my code:

var tasks = new List<Task<RedisValue[]>>();
foreach (var key in keys)
{
   tasks.Add(redisCacheDB.SetMembersAsync(key));
}
var buildLinksJsonArray = await Task.WhenAll(tasks);

For ~120 keys (most of them are not existed), it takes ~10 seconds to finish the pipeline. What am I doing wrong?

I also try SetScan, but I can never get it not timeout. Also, I am not sure I want to execute 120 SetScan sequentially.

Thanks,

Edit: Each set only has ~20 members. I tried some different approach yesterday:

Batching: Take around 5 second

Set Union: Takes around 1~2 second. (I do redis.SetUnion(list of key))

For now I am using the Set Union since it's taking the shortest time. However, I still believe 2 seconds are way longer than it should have taken to retrieve ~120 sets. Anybody have any idea? I am open to suggestion.

Nam Ngo
  • 253
  • 2
  • 11
  • You could try batching or a LUA script: http://stackoverflow.com/questions/27796054/pipelining-vs-batching-in-stackexchange-redis – thepirat000 Oct 28 '16 at 05:29
  • I have not tried LUA script but batching takes 5 seconds. I keep feeling like I am doing something wrong. Retrieving 120 string record takes few hundreds milisecond, so I have no idea why retrieving 120 sets takes that long. – Nam Ngo Oct 28 '16 at 19:01
  • You should try with a LUA script, compare performance and maybe share the results. – thepirat000 Oct 28 '16 at 23:26
  • If you send the name of the redis instance and the time window (including time zone) when you ran this test, we can look a the server side logs also. azurecache at Microsoft dot com – JonCole Oct 29 '16 at 15:54

0 Answers0