For the Redis users and for the StackExchange.Redis driver users, I am trying to initialize the cache by doing mass insertion. To do so, I have tried with a StringSet with an array of 20000 KeyValue and it's failing to time out.
My understanding is by using an array, it is doing an MSET command which should be faster than 20K SET commands. Is it? Has anyone running into this issue? How should I solve it?
Thanks for your help.
The difference between multiple SET and MSET is not as big as you would think - about 10 bytes per item bandwidth, and if you use pipelining (perhaps even the FireAndForget command option): zero latency. But you could also just as easily switch to batches of (say) 100 items: again, this will have additional overhead of about 10 bytes per batch, which is nothing - and these batches could also be pipelined if you want. In either pipelined case, SE.Redis does some work to minimise packet fragmentation etc. Basically, the change I would make here is: don't sent massive batches. Send multiple smaller batches. A huge batch isn't going to give you the benefit you imagine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With