A Node.js module reporting all commands implemented by Redis.
The module gives you access to
- a compiled report
- and a reporting function.
Reports contain info from Redis COMMAND plus data types each command operates on (if applicable).
I developed it as a utility for managing key-to-client binding in node-redis-keychain.
npm install node-redis-commands
var
commands = require('node-redis-commands').commands;
console.log(commands.get); // output below
/*
{ name: 'get',
arity: 2,
flags: [ 'readonly', 'fast' ],
firstKeyAt: 1,
lastKeyAt: 1,
step: 1,
types: [ 'string' ] }
*/
Reporting function issues a COMMAND on a Redis client instance and returns the same list of commands of the compiled report.
This module is client agnostic: you can use your library of choice as long as it exposes both INFO and COMMAND commands.
// module deps
var
Redis = require('ioredis');
report = require('node-redis-commands').report;
var
client = new Redis(),
callback = function (error, version, commands) {
client.disconnect();
if (error) {
throw error;
}
console.log(commands.get); // output below
/*
{ name: 'get',
arity: 2,
flags: [ 'readonly', 'fast' ],
firstKeyAt: 1,
lastKeyAt: 1,
step: 1,
types: [ 'string' ] }
*/
};
report(client, callback);
If you prefer having the list returned as an array
// module deps
var
Redis = require('ioredis');
report = require('node-redis-commands').report;
var
client = new Redis(),
asArray = true,
callback = function (error, version, commands) {
client.disconnect();
if (error) {
throw error;
}
console.log(commands[0]); // output below
/*
{ name: 'hlen',
arity: 2,
flags: [ 'readonly', 'fast' ],
firstKeyAt: 1,
lastKeyAt: 1,
step: 1,
types: [ 'set' ] }
*/
};
report(client, asArray, callback);
Fix redis issue #2598
Fix type for commands operating on keys of type hash
Update compiled report to Redis 3.0.1
Just changed package definition
Added Type
constants
Initial release