Skip to content

Commit 535db52

Browse files
author
Ruben Bridgewater
committed
Fix rename command not working together with key prefixes
1 parent 575ad73 commit 535db52

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -794,17 +794,15 @@ RedisClient.prototype.send_command = function (command, args, callback) {
794794
}
795795
this.command_queue.push(command_obj);
796796

797-
if (typeof this.options.rename_commands !== 'undefined' && this.options.rename_commands[command]) {
798-
command = this.options.rename_commands[command];
799-
}
800797
if (this.options.prefix) {
801798
prefix_keys = commands.getKeyIndexes(command, args_copy);
802-
i = prefix_keys.pop();
803-
while (i !== undefined) {
799+
for (i = prefix_keys.pop(); i !== undefined; i = prefix_keys.pop()) {
804800
args_copy[i] = this.options.prefix + args_copy[i];
805-
i = prefix_keys.pop();
806801
}
807802
}
803+
if (typeof this.options.rename_commands !== 'undefined' && this.options.rename_commands[command]) {
804+
command = this.options.rename_commands[command];
805+
}
808806
// Always use 'Multi bulk commands', but if passed any Buffer args, then do multiple writes, one for each arg.
809807
// This means that using Buffers in commands is going to be slower, so use Strings if you don't already have a Buffer.
810808
command_str = '*' + (len + 1) + '\r\n$' + command.length + '\r\n' + command + '\r\n';

test/rename.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe("rename commands", function () {
2727
});
2828

2929
client.on('ready', function () {
30-
done();
30+
client.flushdb(done);
3131
});
3232
});
3333

0 commit comments

Comments
 (0)