-
Notifications
You must be signed in to change notification settings - Fork 1
@142vip.redis.接口.RedisClientConfig
API 参考 / @142vip/redis / RedisClientConfig
定义于: packages/redis/src/core/redis.interface.ts:18
单机、哨兵配置
RedisOptions
optionalautoPipeliningIgnoredCommands:string[]
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:132
[]RedisOptions.autoPipeliningIgnoredCommands
optionalautoResendUnfulfilledCommands:boolean
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:65
Whether or not to resend unfulfilled commands on reconnect.
Unfulfilled commands are most likely to be blocking commands such as brpop or blpop.
trueRedisOptions.autoResendUnfulfilledCommands
optionalautoResubscribe:boolean
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:59
When the client reconnects, channels subscribed in the previous connection will be
resubscribed automatically if autoResubscribe is true.
trueRedisOptions.autoResubscribe
optionalcommandQueue:boolean
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:134
RedisOptions.commandQueue
optionalcommandTimeout:number
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:13
If a command does not return a reply within a set number of milliseconds, a "Command timed out" error will be thrown.
RedisOptions.commandTimeout
optionalconnectionName:string
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:38
Set the name of the connection to make it easier to identity the connection in client list.
https://redis.io/commands/client-setname
RedisOptions.connectionName
optionalConnector:ConnectorConstructor
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:7
RedisOptions.Connector
optionalconnectTimeout:number
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:102
How long the client will wait before killing a socket due to inactivity during initial connection.
10000RedisOptions.connectTimeout
optionaldb:number
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:53
Database index to use.
0RedisOptions.db
optionaldisconnectTimeout:number
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:41
RedisOptions.disconnectTimeout
optionalenableAutoPipelining:boolean
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:128
falseRedisOptions.enableAutoPipelining
optionalenableOfflineQueue:boolean
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:145
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.
trueRedisOptions.enableOfflineQueue
optionalenableReadyCheck:boolean
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:153
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.
trueRedisOptions.enableReadyCheck
optionalenableTLSForSentinelMode:boolean
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:43
RedisOptions.enableTLSForSentinelMode
optionalfailoverDetector:boolean
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:51
RedisOptions.failoverDetector
optionalfamily:number
定义于: node_modules/.pnpm/@types+node@22.10.7/node_modules/@types/node/net.d.ts:55
RedisOptions.family
optionalhost:string
定义于: node_modules/.pnpm/@types+node@22.10.7/node_modules/@types/node/net.d.ts:51
RedisOptions.host
optionalkeepAlive:number
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:26
Enable/disable keep-alive functionality.
https://nodejs.org/api/net.html#socketsetkeepaliveenable-initialdelay
0RedisOptions.keepAlive
optionalkeyPrefix:string
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/utils/Commander.d.ts:5
RedisOptions.keyPrefix
optionallazyConnect:boolean
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:161
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.
falseRedisOptions.lazyConnect
optionalmaxLoadingRetryTime:number
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:124
10000RedisOptions.maxLoadingRetryTime
optionalmaxRetriesPerRequest:null|number
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:120
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.
20RedisOptions.maxRetriesPerRequest
optionalmonitor:boolean
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:109
This option is used internally when you call redis.monitor() to tell Redis
to enter the monitor mode when the connection is established.
falseRedisOptions.monitor
optionalname:string
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:28
Master group name of the Sentinel
RedisOptions.name
optionalnatMap:NatMap
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:45
RedisOptions.natMap
optionalnoDelay:boolean
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:32
Enable/disable the use of Nagle's algorithm.
https://nodejs.org/api/net.html#socketsetnodelaynodelay
trueRedisOptions.noDelay
optionalofflineQueue:boolean
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:133
RedisOptions.offlineQueue
optionalpassword:string
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:47
If set, client will send AUTH command with the value of this option when connected.
RedisOptions.password
optionalpath:string
定义于: node_modules/.pnpm/@types+node@22.10.7/node_modules/@types/node/net.d.ts:70
RedisOptions.path
optionalport:number
定义于: node_modules/.pnpm/@types+node@22.10.7/node_modules/@types/node/net.d.ts:50
RedisOptions.port
optionalpreferredSlaves:PreferredSlaves
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:39
RedisOptions.preferredSlaves
optionalreadOnly:boolean
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:91
falseRedisOptions.readOnly
optionalreconnectOnError:null|ReconnectOnError
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:87
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:
-
trueor1to trigger a reconnection. -
falseor0to not reconnect. -
2to 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;`
}
},
})nullRedisOptions.reconnectOnError
optionalretryStrategy: (times) =>null|number|void
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:8
number
null | number | void
RedisOptions.retryStrategy
optionalrole:"master"|"slave"
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:32
'master'RedisOptions.role
optionalscripts:Record<string, {lua:string;numberOfKeys?:number;readOnly?:boolean; }>
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:165
undefinedRedisOptions.scripts
optionalsentinelCommandTimeout:number
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:42
RedisOptions.sentinelCommandTimeout
optionalsentinelMaxConnections:number
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:50
10RedisOptions.sentinelMaxConnections
optionalsentinelPassword:string
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:35
RedisOptions.sentinelPassword
optionalsentinelReconnectStrategy: (retryAttempts) =>null|number|void
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:38
number
null | number | void
RedisOptions.sentinelReconnectStrategy
optionalsentinelRetryStrategy: (retryAttempts) =>null|number|void
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:37
number
null | number | void
RedisOptions.sentinelRetryStrategy
optionalsentinels:Partial<SentinelAddress>[]
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:36
RedisOptions.sentinels
optionalsentinelTLS:ConnectionOptions
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:44
RedisOptions.sentinelTLS
optionalsentinelUsername:string
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:34
RedisOptions.sentinelUsername
optionalshowFriendlyErrorStack:boolean
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/utils/Commander.d.ts:6
RedisOptions.showFriendlyErrorStack
optionalsocketTimeout:number
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:20
If the socket does not receive data within a set number of milliseconds:
- the socket is considered "dead" and will be destroyed
- the client will reject any running commands (altought they might have been processed by the server)
- the reconnect strategy will kick in (depending on the configuration)
RedisOptions.socketTimeout
optionalstringNumbers:boolean
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:97
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).
falseRedisOptions.stringNumbers
optionaltls:ConnectionOptions
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:33
RedisOptions.tls
optionalupdateSentinels:boolean
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:46
RedisOptions.updateSentinels
optionalurl:string
定义于: packages/redis/src/core/redis.interface.ts:19
optionalusername:string
定义于: node_modules/.pnpm/ioredis@5.6.0/node_modules/ioredis/built/redis/RedisOptions.d.ts:43
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.
RedisOptions.username
- @142vip/axios
- @142vip/changelog
- @142vip/commit-linter
- @142vip/copyright
- @142vip/data-source
- @142vip/eslint-config
- @142vip/fairy-cli
- @142vip/grpc
- @142vip/nest
- @142vip/nest-redis
- @142vip/nest-typeorm
- @142vip/oauth2.0
- @142vip/open-source
- @142vip/redis
- @142vip/release-version
- @142vip/typeorm
- @142vip/utils