1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Implement CLIENT REPLY ON|OFF|SKIP

This commit is contained in:
Ruben Bridgewater
2016-04-14 01:17:43 +02:00
parent 3038c9043d
commit 97ae78877b
5 changed files with 233 additions and 24 deletions

View File

@@ -150,6 +150,7 @@ function RedisClient (options, stream) {
this.times_connected = 0;
this.options = options;
this.buffers = options.return_buffers || options.detect_buffers;
this.reply = 'ON'; // Returning replies is the default
// Init parser
this.reply_parser = create_parser(this, options);
this.create_stream();
@@ -901,6 +902,22 @@ RedisClient.prototype.internal_send_command = function (command, args, callback,
if (call_on_write) {
call_on_write();
}
// Handle `CLIENT REPLY ON|OFF|SKIP`
// This has to be checked after call_on_write
if (this.reply === 'ON') {
this.command_queue.push(command_obj);
} else {
// Do not expect a reply
// Does this work in combination with the pub sub mode?
if (callback) {
utils.reply_in_order(this, callback, null, undefined, this.command_queue);
}
if (this.reply === 'SKIP') {
this.reply = 'SKIP_ONE_MORE';
} else if (this.reply === 'SKIP_ONE_MORE') {
this.reply = 'ON';
}
}
return !this.should_buffer;
};