h0x91b / redis-fast-driver

78 stars 13 forks source link

Pipelining #35

Closed sirganya closed 4 years ago

sirganya commented 4 years ago

Thanks again for the great driver. I was wondering if you had any plans to implement pipelining?

h0x91b commented 4 years ago

Thanks for warm words, the driver is working using async API, async API works by nature as pipelining, so no speed boost will be archived.

But any way you still can use pipelining to make sure that all transaction will be done in one request:

r.rawCall(['multi']);
r.rawCall(['echo', 'hello world']);
r.rawCall(['ping']);
r.rawCall(['incr', 'qqq']);
r.rawCall(['set', 'foo', 'bar']);
r.rawCall(['get', 'foo']);
r.rawCall(['exec'], function(e, resp){
    console.log('exec resp', resp);
});

In the console you will see:

exec resp [ 'hello world', 'PONG', 4, 'OK', 'bar' ]
sirganya commented 4 years ago

Good to know. Thanks for explaining. It might be worth documenting that on the front page. All the other popular drivers mention pipelining.

h0x91b commented 4 years ago

I will add an example to the front page.