-
Notifications
You must be signed in to change notification settings - Fork 24
Pipelining
Andrey Bulygin edited this page May 21, 2013
·
1 revision
Since Redis server supports pipelining, RedisBoost also supports it.
Any command that is sent to Redis is pipelined. The pipeline is flushed to network as soon as possible. Within redisboost there is a sort of competition between how fast the network is and how fast new commands are added to pipeline. The greater the density of commands is the more efficiently network is used.
Let's see an example
[Test]
public void PipelineTest()
{
using (var cli = CreateClient())
{
var tasks = new List<Task<Bulk>>()
for (int i = 0; i < 10000; i++)
{
cli.SetAsync("Key" + i, "Value" + i);
tasks.Add(cli.GetAsync("Key" + i));
}
// some other work here...
//...
for (int i = 0; i < 10000; i++)
Assert.AreEqual("Value" + i, tasks[i].Result.As<string>());
}
}
Please consider the example above. As you can see it executes 10000 commands, and does not wait until the end of execution.
At the end all responses are checked.
In the test library NBoosters.RedisBoost.Tests there is a IntegrationTests.PipelineTest_ParallelPipelining test that shows parallel work with the same redis client in pipeline style