@142vip.redis.接口.RedisClientConfig - 142vip/core-x GitHub Wiki
API 参考 / @142vip/redis / RedisClientConfig
接口: RedisClientConfig
定义于: packages/redis/src/core/redis.interface.ts:18
单机、哨兵配置
theme_extends
RedisOptions
theme_extended_by
属性
autoPipeliningIgnoredCommands?
optionalautoPipeliningIgnoredCommands:string[]
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/redis/RedisOptions.d.ts:132
默认值
[]
继承自
RedisOptions.autoPipeliningIgnoredCommands
autoResendUnfulfilledCommands?
optionalautoResendUnfulfilledCommands:boolean
定义于: node_modules/.pnpm/[email protected]/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.
默认值
true
继承自
RedisOptions.autoResendUnfulfilledCommands
autoResubscribe?
optionalautoResubscribe:boolean
定义于: node_modules/.pnpm/[email protected]/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.
默认值
true
继承自
RedisOptions.autoResubscribe
commandQueue?
optionalcommandQueue:boolean
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/redis/RedisOptions.d.ts:134
继承自
RedisOptions.commandQueue
commandTimeout?
optionalcommandTimeout:number
定义于: node_modules/.pnpm/[email protected]/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
connectionName?
optionalconnectionName:string
定义于: node_modules/.pnpm/[email protected]/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
Connector?
optionalConnector:ConnectorConstructor
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/redis/RedisOptions.d.ts:7
继承自
RedisOptions.Connector
connectTimeout?
optionalconnectTimeout:number
定义于: node_modules/.pnpm/[email protected]/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.
默认值
10000
继承自
RedisOptions.connectTimeout
db?
optionaldb:number
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/redis/RedisOptions.d.ts:53
Database index to use.
默认值
0
继承自
RedisOptions.db
disconnectTimeout?
optionaldisconnectTimeout:number
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:41
继承自
RedisOptions.disconnectTimeout
enableAutoPipelining?
optionalenableAutoPipelining:boolean
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/redis/RedisOptions.d.ts:128
默认值
false
继承自
RedisOptions.enableAutoPipelining
enableOfflineQueue?
optionalenableOfflineQueue:boolean
定义于: node_modules/.pnpm/[email protected]/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.
默认值
true
继承自
RedisOptions.enableOfflineQueue
enableReadyCheck?
optionalenableReadyCheck:boolean
定义于: node_modules/.pnpm/[email protected]/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.
默认值
true
继承自
RedisOptions.enableReadyCheck
enableTLSForSentinelMode?
optionalenableTLSForSentinelMode:boolean
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:43
继承自
RedisOptions.enableTLSForSentinelMode
failoverDetector?
optionalfailoverDetector:boolean
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:51
继承自
RedisOptions.failoverDetector
family?
optionalfamily:number
定义于: node_modules/.pnpm/@[email protected]/node_modules/@types/node/net.d.ts:55
继承自
RedisOptions.family
host?
optionalhost:string
定义于: node_modules/.pnpm/@[email protected]/node_modules/@types/node/net.d.ts:51
继承自
RedisOptions.host
keepAlive?
optionalkeepAlive:number
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/redis/RedisOptions.d.ts:26
Enable/disable keep-alive functionality.
链接
https://nodejs.org/api/net.html#socketsetkeepaliveenable-initialdelay
默认值
0
继承自
RedisOptions.keepAlive
keyPrefix?
optionalkeyPrefix:string
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/utils/Commander.d.ts:5
继承自
RedisOptions.keyPrefix
lazyConnect?
optionallazyConnect:boolean
定义于: node_modules/.pnpm/[email protected]/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.
默认值
false
继承自
RedisOptions.lazyConnect
maxLoadingRetryTime?
optionalmaxLoadingRetryTime:number
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/redis/RedisOptions.d.ts:124
默认值
10000
继承自
RedisOptions.maxLoadingRetryTime
maxRetriesPerRequest?
optionalmaxRetriesPerRequest:null|number
定义于: node_modules/.pnpm/[email protected]/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.
默认值
20
继承自
RedisOptions.maxRetriesPerRequest
monitor?
optionalmonitor:boolean
定义于: node_modules/.pnpm/[email protected]/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.
默认值
false
继承自
RedisOptions.monitor
name?
optionalname:string
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:28
Master group name of the Sentinel
继承自
RedisOptions.name
natMap?
optionalnatMap:NatMap
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:45
继承自
RedisOptions.natMap
noDelay?
optionalnoDelay:boolean
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/redis/RedisOptions.d.ts:32
Enable/disable the use of Nagle's algorithm.
链接
https://nodejs.org/api/net.html#socketsetnodelaynodelay
默认值
true
继承自
RedisOptions.noDelay
offlineQueue?
optionalofflineQueue:boolean
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/redis/RedisOptions.d.ts:133
继承自
RedisOptions.offlineQueue
password?
optionalpassword:string
定义于: node_modules/.pnpm/[email protected]/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
path?
optionalpath:string
定义于: node_modules/.pnpm/@[email protected]/node_modules/@types/node/net.d.ts:70
继承自
RedisOptions.path
port?
optionalport:number
定义于: node_modules/.pnpm/@[email protected]/node_modules/@types/node/net.d.ts:50
继承自
RedisOptions.port
preferredSlaves?
optionalpreferredSlaves:PreferredSlaves
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:39
继承自
RedisOptions.preferredSlaves
readOnly?
optionalreadOnly:boolean
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/redis/RedisOptions.d.ts:91
默认值
false
继承自
RedisOptions.readOnly
reconnectOnError?
optionalreconnectOnError:null|ReconnectOnError
定义于: node_modules/.pnpm/[email protected]/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;`
}
},
})
默认值
null
继承自
RedisOptions.reconnectOnError
retryStrategy()?
optionalretryStrategy: (times) =>null|number|void
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/redis/RedisOptions.d.ts:8
参数
times
number
返回
null | number | void
继承自
RedisOptions.retryStrategy
role?
optionalrole:"master"|"slave"
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:32
默认值
'master'
继承自
RedisOptions.role
scripts?
optionalscripts:Record<string, {lua:string;numberOfKeys?:number;readOnly?:boolean; }>
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/redis/RedisOptions.d.ts:165
默认值
undefined
继承自
RedisOptions.scripts
sentinelCommandTimeout?
optionalsentinelCommandTimeout:number
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:42
继承自
RedisOptions.sentinelCommandTimeout
sentinelMaxConnections?
optionalsentinelMaxConnections:number
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:50
默认值
10
继承自
RedisOptions.sentinelMaxConnections
sentinelPassword?
optionalsentinelPassword:string
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:35
继承自
RedisOptions.sentinelPassword
sentinelReconnectStrategy()?
optionalsentinelReconnectStrategy: (retryAttempts) =>null|number|void
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:38
参数
retryAttempts
number
返回
null | number | void
继承自
RedisOptions.sentinelReconnectStrategy
sentinelRetryStrategy()?
optionalsentinelRetryStrategy: (retryAttempts) =>null|number|void
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:37
参数
retryAttempts
number
返回
null | number | void
继承自
RedisOptions.sentinelRetryStrategy
sentinels?
optionalsentinels:Partial<SentinelAddress>[]
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:36
继承自
RedisOptions.sentinels
sentinelTLS?
optionalsentinelTLS:ConnectionOptions
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:44
继承自
RedisOptions.sentinelTLS
sentinelUsername?
optionalsentinelUsername:string
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:34
继承自
RedisOptions.sentinelUsername
showFriendlyErrorStack?
optionalshowFriendlyErrorStack:boolean
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/utils/Commander.d.ts:6
继承自
RedisOptions.showFriendlyErrorStack
socketTimeout?
optionalsocketTimeout:number
定义于: node_modules/.pnpm/[email protected]/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
stringNumbers?
optionalstringNumbers:boolean
定义于: node_modules/.pnpm/[email protected]/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).
默认值
false
继承自
RedisOptions.stringNumbers
tls?
optionaltls:ConnectionOptions
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:33
继承自
RedisOptions.tls
updateSentinels?
optionalupdateSentinels:boolean
定义于: node_modules/.pnpm/[email protected]/node_modules/ioredis/built/connectors/SentinelConnector/index.d.ts:46
继承自
RedisOptions.updateSentinels
url?
optionalurl:string
定义于: packages/redis/src/core/redis.interface.ts:19
username?
optionalusername:string
定义于: node_modules/.pnpm/[email protected]/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