// When no callback provided, Command instance will have a `promise` property, // which will resolve/reject with the result of the command. vargetCommand = newCommand('get', ['foo']); getCommand.promise.then(function (result) { console.log('result', result); });
Extract the blocking timeout from the command arguments.
Returns number
The timeout in seconds, null for indefinite blocking (timeout of 0),
or undefined if this is not a blocking command
getKeys
getKeys(): (string | Buffer)[]
Returns (string | Buffer)[]
getSlot
getSlot(): number
Returns number
setBlockingTimeout
setBlockingTimeout(ms): void
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.
Parameters
ms: number
Returns void
setReplyContext
setReplyContext(context): void
Parameters
context: ReplyContext
Returns void
setTimeout
setTimeout(ms): void
Set the wait time before terminating the attempt to execute a command
and generating an error.
Command instance
It's rare that you need to create a Command instance yourself.