docs/interfaces/CommonRedisOptions.html
interface CommonRedisOptions {
Connector?: ConnectorConstructor;
autoPipeliningIgnoredCommands?: string[];
autoResendUnfulfilledCommands?: boolean;
autoResubscribe?: boolean;
blockingTimeout?: number;
blockingTimeoutGrace?: number;
clientInfoTag?: string;
commandQueue?: boolean;
commandTimeout?: number;
connectTimeout?: number;
connectionName?: string;
db?: number;
disableClientInfo?: boolean;
enableAutoPipelining?: boolean;
enableOfflineQueue?: boolean;
enableReadyCheck?: boolean;
himportFieldsets?: readonly HimportFieldset[];
keepAlive?: number;
keyPrefix?: string;
lazyConnect?: boolean;
maxLoadingRetryTime?: number;
maxRetriesPerRequest?: number;
monitor?: boolean;
noDelay?: boolean;
offlineQueue?: boolean;
password?: string;
protocol?: ProtocolVersion;
readOnly?: boolean;
reconnectOnError?: ReconnectOnError;
replyMapping?: ReplyMappingMode;
retryStrategy?: ((times) => number | void);
scripts?: Record<string, {
lua: string;
numberOfKeys?: number;
readOnly?: boolean;
}>;
showFriendlyErrorStack?: boolean;
socketTimeout?: number;
stringNumbers?: boolean;
username?: string;
}
Connector?autoPipeliningIgnoredCommands?autoResendUnfulfilledCommands?autoResubscribe?blockingTimeout?blockingTimeoutGrace?clientInfoTag?commandQueue?commandTimeout?connectTimeout?connectionName?db?disableClientInfo?enableAutoPipelining?enableOfflineQueue?enableReadyCheck?himportFieldsets?keepAlive?keyPrefix?lazyConnect?maxLoadingRetryTime?maxRetriesPerRequest?monitor?noDelay?offlineQueue?password?protocol?readOnly?reconnectOnError?replyMapping?retryStrategy?scripts?showFriendlyErrorStack?socketTimeout?stringNumbers?username?
Optional ConnectorConnector?: ConnectorConstructor
Optional autoPipeliningIgnoredCommandsautoPipeliningIgnoredCommands?: string[]
[]Copy
Optional autoResendUnfulfilledCommandsautoResendUnfulfilledCommands?: boolean
Whether or not to resend unfulfilled commands on reconnect. Unfulfilled commands are most likely to be blocking commands such as brpop or blpop.
trueCopy
Optional autoResubscribeautoResubscribe?: boolean
When the client reconnects, channels subscribed in the previous connection will be resubscribed automatically if autoResubscribe is true.
trueCopy
Optional blockingTimeoutblockingTimeout?: number
Enables client-side timeout protection for blocking commands when set to a positive number. If blockingTimeout is undefined, 0, or negative (e.g. -1), the protection is disabled and no client-side timers are installed for blocking commands.
Optional blockingTimeoutGraceblockingTimeoutGrace?: number
Grace period (ms) added to blocking command timeouts. Only used when blockingTimeout is a positive number. Defaults to 100ms.
Optional clientInfoTagclientInfoTag?: string
Tag to append to the library name in CLIENT SETINFO (ioredis(tag)).
https://redis.io/docs/latest/commands/client-setinfo/
undefinedCopy
Optional commandQueuecommandQueue?: boolean
Optional commandTimeoutcommandTimeout?: number
If a command does not return a reply within a set number of milliseconds, a "Command timed out" error will be thrown.
Optional connectTimeoutconnectTimeout?: number
How long the client will wait before killing a socket due to inactivity during initial connection.
10000Copy
Optional connectionNameconnectionName?: string
Set the name of the connection to make it easier to identity the connection in client list.
https://redis.io/commands/client-setname
Optional dbdb?: number
Database index to use.
0Copy
Optional disableClientInfodisableClientInfo?: boolean
If true, skips setting library info via CLIENT SETINFO.
https://redis.io/docs/latest/commands/client-setinfo/
falseCopy
Optional enableAutoPipeliningenableAutoPipelining?: boolean
falseCopy
Optional enableOfflineQueueenableOfflineQueue?: boolean
By default, if the connection to Redis server has not been established, commands are added to a queue and are executed once the connection is "ready" (when enableReadyCheck is true, "ready" means the Redis server has loaded the database from disk, otherwise means the connection to the Redis server has been established). If this option is false, when execute the command when the connection isn't ready, an error will be returned.
trueCopy
Optional enableReadyCheckenableReadyCheck?: boolean
The client will sent an INFO command to check whether the server is still loading data from the disk ( which happens when the server is just launched) when the connection is established, and only wait until the loading process is finished before emitting the ready event.
trueCopy
Optional Experimental himportFieldsetshimportFieldsets?: readonly HimportFieldset[]
Managed-fieldset support is experimental and requires Redis 8.10 or newer.
Long-lived HIMPORT fieldsets managed for the lifetime of this client. Definitions are copied during construction and prepared again whenever the physical Redis connection changes.
When a managed HIMPORT SET needs fieldset preparation or recovery, later commands issued on this client may be sent before that SET resumes. Await the SET before issuing commands that depend on its write.
Explicit pipelines containing a managed HIMPORT SET wait for required fieldset preparation before the batch is sent.
Background preparation failures do not prevent the connection from becoming ready and are reported through the error event. A dependent managed HIMPORT SET retries preparation and rejects if recovery fails.
Use explicit HIMPORT PREPARE and DISCARD commands on a separate client for bounded, manually managed batches.
undefined@experimentalCopy
Optional keepAlivekeepAlive?: number
Initial delay in milliseconds before the first TCP keep-alive probe.
https://nodejs.org/api/net.html#socketsetkeepaliveenable-initialdelay
30000Copy
Optional keyPrefixkeyPrefix?: string
Optional lazyConnectlazyConnect?: boolean
When a Redis instance is initialized, a connection to the server is immediately established. Set this to true will delay the connection to the server until the first command is sent or redis.connect() is called explicitly. When redis.connect() is called explicitly, a Promise is returned, which will be resolved when the connection is ready or rejected when it fails. The rejection should be handled by the user.
falseCopy
Optional maxLoadingRetryTimemaxLoadingRetryTime?: number
10000Copy
Optional maxRetriesPerRequestmaxRetriesPerRequest?: number
The commands that don't get a reply due to the connection to the server is lost are put into a queue and will be resent on reconnect (if allowed by the retryStrategy option). This option is used to configure how many reconnection attempts should be allowed before the queue is flushed with a MaxRetriesPerRequestError error. Set this options to null instead of a number to let commands wait forever until the connection is alive again.
20Copy
Optional monitormonitor?: boolean
This option is used internally when you call redis.monitor() to tell Redis to enter the monitor mode when the connection is established.
falseCopy
Optional noDelaynoDelay?: boolean
Enable/disable the use of Nagle's algorithm.
https://nodejs.org/api/net.html#socketsetnodelaynodelay
trueCopy
Optional offlineQueueofflineQueue?: boolean
Optional passwordpassword?: string
If set, client will send AUTH command with the value of this option when connected.
Optional protocolprotocol?: ProtocolVersion
The RESP protocol version to use.
3Copy
Optional readOnlyreadOnly?: boolean
falseCopy
Optional reconnectOnErrorreconnectOnError?: ReconnectOnError
Whether or not to reconnect on certain Redis errors. This options by default is null, which means it should never reconnect on Redis errors. You can pass a function that accepts an Redis error, and returns:
true or 1 to trigger a reconnection.false or 0 to not reconnect.2 to reconnect and resend the failed command (who triggered the error) after reconnection.const redis = new Redis({ reconnectOnError(err) { const targetError = "READONLY"; if (err.message.includes(targetError)) { // Only reconnect when the error contains "READONLY" return true; // or `return 1;` } },});Copy
nullCopy
Optional replyMappingreplyMapping?: ReplyMappingMode
How RESP3-only reply types are represented in JavaScript. Only supported when protocol is 3.
"legacy" (default): RESP2-compatible shapes. Map replies arrive as flat [key, value, ...] arrays and doubles as strings, so replies are identical across both protocols."resp3": map replies arrive as plain objects (with string keys) and doubles as numbers."legacy"Copy
Optional retryStrategyretryStrategy?: ((times) => number | void)
Determines the delay in milliseconds before reconnecting after a connection loss.
- times: number
Exponential backoff capped at 5000ms, plus 0-199ms of random jitter.Copy
Optional scriptsscripts?: Record<string, {
lua: string;
numberOfKeys?: number;
readOnly?: boolean;
}>
Optional numberOfKeys?: numberOptional readOnly?: booleanundefinedCopy
Optional showFriendlyErrorStackshowFriendlyErrorStack?: boolean
Optional socketTimeoutsocketTimeout?: number
If the socket does not receive data within a set number of milliseconds:
Optional stringNumbersstringNumbers?: boolean
When enabled, numbers returned by Redis will be converted to JavaScript strings instead of numbers. This is necessary if you want to handle big numbers (above Number.MAX_SAFE_INTEGER === 2^53).
falseCopy
Optional usernameusername?: string
If set, client will send AUTH command with the value of this option as the first argument when connected. This is supported since Redis 6.
OSLightDark
ConnectorautoPipeliningIgnoredCommandsautoResendUnfulfilledCommandsautoResubscribeblockingTimeoutblockingTimeoutGraceclientInfoTagcommandQueuecommandTimeoutconnectTimeoutconnectionNamedbdisableClientInfoenableAutoPipeliningenableOfflineQueueenableReadyCheckhimportFieldsetskeepAlivekeyPrefixlazyConnectmaxLoadingRetryTimemaxRetriesPerRequestmonitornoDelayofflineQueuepasswordprotocolreadOnlyreconnectOnErrorreplyMappingretryStrategyscriptsshowFriendlyErrorStacksocketTimeoutstringNumbersusername