Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface RedisOptions

Hierarchy

  • RedisOptions

Index

Properties

Optional autoResendUnfulfilledCommands

autoResendUnfulfilledCommands: boolean

If true, client will resend unfulfilled commands(e.g. block commands) in the previous connection when reconnected. default: true.

Optional autoResubscribe

autoResubscribe: boolean

After reconnected, if the previous connection was in the subscriber mode, client will auto re-subscribe these channels. default: true.

Optional commandTimeout

commandTimeout: number

The milliseconds before a timeout occurs when executing a single command. By default, there is no timeout and the client will wait indefinitely. The timeout is enforced only on the client side, not server side. The server may still complete the operation after a timeout error occurs on the client side.

Optional connectTimeout

connectTimeout: number

The milliseconds before a timeout occurs during the initial connection to the Redis server. default: 10000.

Optional connectionName

connectionName: string

Optional db

db: number

Database index to use.

Optional dropBufferSupport

dropBufferSupport: boolean

If you are using the hiredis parser, it's highly recommended to enable this option. Create another instance with dropBufferSupport disabled for other commands that you want to return binary instead of string

Optional enableAutoPipelining

enableAutoPipelining: boolean

When enabled, all commands issued during an event loop iteration are automatically wrapped in a pipeline and sent to the server at the same time. This can improve performance by 30-50%. default: false.

Optional enableOfflineQueue

enableOfflineQueue: boolean

By default, if there is no active connection to the Redis server, 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.

Optional enableReadyCheck

enableReadyCheck: boolean

When a connection is established to the Redis server, the server might still be loading the database from disk. While loading, the server not respond to any commands. To work around this, when this option is true, ioredis will check the status of the Redis server, and when the Redis server is able to process commands, a ready event will be emitted.

Optional enableTLSForSentinelMode

enableTLSForSentinelMode: boolean

Whether to support the tls option when connecting to Redis via sentinel mode. default: false.

Optional family

family: number

4 (IPv4) or 6 (IPv6), Defaults to 4.

Optional host

host: string

Optional keepAlive

keepAlive: number

TCP KeepAlive on the socket with a X ms delay before start. Set to a non-number value to disable keepAlive.

Optional keyPrefix

keyPrefix: string

Optional lazyConnect

lazyConnect: boolean

Optional maxRetriesPerRequest

maxRetriesPerRequest: null | number

By default, all pending commands will be flushed with an error every 20 retry attempts. That makes sure commands won't wait forever when the connection is down. You can change this behavior by setting maxRetriesPerRequest.

Set maxRetriesPerRequest to null to disable this behavior, and every command will wait forever until the connection is alive again (which is the default behavior before ioredis v4).

Optional maxScriptsCachingTime

maxScriptsCachingTime: number

Default script definition caching time.

Optional name

name: string

default: null.

Optional natMap

natMap: NatMap

NAT map for sentinel connector. default: null.

Optional noDelay

noDelay: boolean

Whether to disable the Nagle's Algorithm.

Optional password

password: string

If set, client will send AUTH command with the value of this option when connected.

Optional path

path: string

Local domain socket path. If set the port, host and family will be ignored.

Optional port

port: number

Optional preferredSlaves

preferredSlaves: PreferredSlaves

Can be used to prefer a particular slave or set of slaves based on priority.

Optional readOnly

readOnly: boolean

Enable READONLY mode for the connection. Only available for cluster mode. default: false.

Optional role

role: "master" | "slave"

default: "master".

Optional sentinelPassword

sentinelPassword: string

Optional sentinelTLS

sentinelTLS: SecureContextOptions

Optional sentinelUsername

sentinelUsername: string

Optional sentinels

sentinels: { host: string; port: number }[]

Optional showFriendlyErrorStack

showFriendlyErrorStack: boolean

Whether to show a friendly error stack. Will decrease the performance significantly.

Optional stringNumbers

stringNumbers: boolean

Force numbers to be always returned as JavaScript strings. This option is necessary when dealing with big numbers (exceed the [-2^53, +2^53] range).

Optional tls

tls: ConnectionOptions

Optional updateSentinels

updateSentinels: boolean

Update the given sentinels list with new IP addresses when communicating with existing sentinels. default: true.

Optional username

username: string

If set, client will send AUTH command with the value of this option as the first argument when connected. The password option must be set too. Username should only be set for Redis >=6.

Methods

Optional reconnectOnError

  • reconnectOnError(error: Error): boolean | 1 | 2
  • 1/true means reconnect, 2 means reconnect and resend failed command. Returning false will ignore the error and do nothing.

    Parameters

    • error: Error

    Returns boolean | 1 | 2

Optional retryStrategy

  • retryStrategy(times: number): null | number | void

Optional sentinelRetryStrategy

  • sentinelRetryStrategy(times: number): null | number | void
  • If sentinelRetryStrategy returns a valid delay time, ioredis will try to reconnect from scratch. default: function(times) { return Math.min(times * 10, 1000); }

    Parameters

    • times: number

    Returns null | number | void

Generated using TypeDoc