node-redis icon indicating copy to clipboard operation
node-redis copied to clipboard

Space-delimited commands are not handled by client.send_command()

Open thauburger opened this issue 14 years ago • 3 comments

Issue resolved in pull request #181

This morning, I attempted to use send_command() to executeDEBUG OBJECT on a Redis key. This resulted in the error: " ERR unknown command 'debug object' ".

DEBUG OBJECT is one of the commands listed in lib/commands.js, and is successfully added to the RedisClient prototype object during initialization.

However, neither method of invocation seemed to be working:

  • client['DEBUG OBJECT']()
  • client.send_command('DEBUG OBJECT' .... )

Since send_command() issues all commands in the multi-bulk format, I started examining the construction of the raw format strings.

If we take the DEBUG OBJECT example:

The existing approach bundled the command as a single element in the multi-bulk request:

*2
$12
DEBUG OBJECT
$7
testkey

Unfortunately, it appears as though Redis rejects this format when the command includes a space.

I've submitted a patch for send_command() in pull request #181.

The patched approach first parses the command string for multiple words, and then gives each word its own element in the multi-bulk request:

*3
$5
DEBUG
$6
OBJECT
$7
testkey

This appears to be fully functional for me.

By my count, there are currently 5 commands in Redis which are space-delimited:

  • CONFIG GET
  • CONFIG SET
  • CONFIG RESETSTAT
  • DEBUG OBJECT
  • DEBUG SEGFAULT

My understanding is that send_command() is designed to mirror redis-cli functionality from within a node process. This patch helps provide more complete command support (which I believe is now at 100%).

Thanks!

thauburger avatar Mar 04 '12 13:03 thauburger

This should work now!

Cheers, D

DTrejo avatar Feb 24 '13 04:02 DTrejo

This doesn't work for me.

db.client.send_command('debug object', [key], function(err, result) { });

I get back [Error: ERR unknown command 'debug object']

barisusakli avatar Dec 12 '13 00:12 barisusakli

Nevermind found the other issue.

 cliend.debug('object', key, function(err, result) {});

works.

barisusakli avatar Dec 12 '13 00:12 barisusakli