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

Fix rename command not working together with key prefixes

This commit is contained in:
Ruben Bridgewater
2016-03-01 17:13:31 +01:00
parent 575ad7357b
commit 535db5231e
2 changed files with 5 additions and 7 deletions

View File

@@ -794,17 +794,15 @@ RedisClient.prototype.send_command = function (command, args, callback) {
} }
this.command_queue.push(command_obj); this.command_queue.push(command_obj);
if (typeof this.options.rename_commands !== 'undefined' && this.options.rename_commands[command]) {
command = this.options.rename_commands[command];
}
if (this.options.prefix) { if (this.options.prefix) {
prefix_keys = commands.getKeyIndexes(command, args_copy); prefix_keys = commands.getKeyIndexes(command, args_copy);
i = prefix_keys.pop(); for (i = prefix_keys.pop(); i !== undefined; i = prefix_keys.pop()) {
while (i !== undefined) {
args_copy[i] = this.options.prefix + args_copy[i]; args_copy[i] = this.options.prefix + args_copy[i];
i = prefix_keys.pop();
} }
} }
if (typeof this.options.rename_commands !== 'undefined' && this.options.rename_commands[command]) {
command = this.options.rename_commands[command];
}
// Always use 'Multi bulk commands', but if passed any Buffer args, then do multiple writes, one for each arg. // Always use 'Multi bulk commands', but if passed any Buffer args, then do multiple writes, one for each arg.
// This means that using Buffers in commands is going to be slower, so use Strings if you don't already have a Buffer. // This means that using Buffers in commands is going to be slower, so use Strings if you don't already have a Buffer.
command_str = '*' + (len + 1) + '\r\n$' + command.length + '\r\n' + command + '\r\n'; command_str = '*' + (len + 1) + '\r\n$' + command.length + '\r\n' + command + '\r\n';

View File

@@ -27,7 +27,7 @@ describe("rename commands", function () {
}); });
client.on('ready', function () { client.on('ready', function () {
done(); client.flushdb(done);
}); });
}); });