docs/classes/Command.html
Command instance
It's rare that you need to create a Command instance yourself.
var infoCommand = new Command('info', null, function (err, result) { console.log('result', result);});redis.sendCommand(infoCommand);// When no callback provided, Command instance will have a `promise` property,// which will resolve/reject with the result of the command.var getCommand = new Command('get', ['foo']);getCommand.promise.then(function (result) { console.log('result', result);});Copy
argsignore?inTransactionisReadOnly?isResolvedisSettledisTracednamepipelineIndex?promiserejectresolveFLAGS
extractBlockingTimeoutgetKeysgetSlotsetBlockingTimeoutsetReplyContextsetTimeoutstringifyArgumentstoWritabletransformReplycheckFlagsetArgumentTransformersetReplyTransformer
Creates an instance of Command.
Command name
An array of command arguments
options: CommandOptions = {}
Optional callback: Callback
The callback that handles the response. If omit, the response will be handled via Promise
args: CommandParameter[]
Optional ignoreignore?: boolean
inTransaction: boolean = false
Optional isReadOnlyisReadOnly?: boolean
isResolved: boolean = false
isSettled: boolean = false
isTraced: boolean = false
name: string
Command name
Optional pipelineIndexpipelineIndex?: number
promise: Promise<any>
reject: ((err) => void)
- err: Error
resolve: ((result) => void)
- result: any
Static FLAGSFLAGS: {
BLOCKING_COMMANDS: ["blpop", "brpop", "brpoplpush", "blmove", "blmovem", "bzpopmin", "bzpopmax", "bzmpop", "blmpop", "xread", "xreadgroup"];
BLOCK_OPTION_COMMANDS: ["xread", "xreadgroup"];
ENTER_SUBSCRIBER_MODE: ["subscribe", "psubscribe", "ssubscribe"];
EXIT_SUBSCRIBER_MODE: ["unsubscribe", "punsubscribe", "sunsubscribe"];
FIRST_ARG_TIMEOUT_COMMANDS: ["bzmpop", "blmpop"];
HANDSHAKE_COMMANDS: ["auth", "hello", "select", "client", "readonly", "info"];
IGNORE_RECONNECT_ON_ERROR: ["client"];
LAST_ARG_TIMEOUT_COMMANDS: ["blpop", "brpop", "brpoplpush", "blmove", "bzpopmin", "bzpopmax"];
VALID_IN_MONITOR_MODE: ["monitor", "auth"];
VALID_IN_SUBSCRIBER_MODE: ["subscribe", "psubscribe", "unsubscribe", "punsubscribe", "ssubscribe", "sunsubscribe", "ping", "quit"];
WILL_DISCONNECT: ["quit"];
} = ...
Extract the blocking timeout from the command arguments.
The timeout in seconds, null for indefinite blocking (timeout of 0), or undefined if this is not a blocking command
Set a timeout for blocking commands. When the timeout expires, the command resolves with null (matching Redis behavior). This handles the case of undetectable network failures (e.g., docker network disconnect) where the TCP connection becomes a zombie and no close event fires.
Set the wait time before terminating the attempt to execute a command and generating an error.
Convert command to writable buffer or string
Convert buffer/buffer[] to string/string[], and apply reply transformer.
Static checkFlagCheck whether the command has the flag
Static setArgumentTransformerStatic setReplyTransformerOSLightDark
constructorargsignoreinTransactionisReadOnlyisResolvedisSettledisTracednamepipelineIndexpromiserejectresolveFLAGSextractBlockingTimeoutgetKeysgetSlotsetBlockingTimeoutsetReplyContextsetTimeoutstringifyArgumentstoWritabletransformReplycheckFlagsetArgumentTransformersetReplyTransformer