I am trying to insert a large(-ish) number of elements in the shortest time possible and I tried these two alternatives:
1) Pipelining:
List
Behind the scenes, SE.Redis does quite a bit of work to try to avoid packet fragmentation, so it isn't surprising that it is quite similar in your case. The main difference between batching and flat pipelining are:
multi
/exec
transaction or a Lua script)In most cases, you will do better by avoiding batching, since SE.Redis achieves most of what it does automatically when simply adding work.
As a final note; if you want to avoid local overhead, one final approach might be:
redisDB.SetAdd(string.Format(keyFormat, row.Field<int>("Id")),
row.Field<int>("Value"), flags: CommandFlags.FireAndForget);
This sends everything down the wire, neither waiting for responses nor allocating incomplete Task
s to represent future values. You might want to do something like a Ping
at the end without fire-and-forget, to check the server is still talking to you. Note that using fire-and-forget does mean that you won't notice any server errors that get reported.