You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
33 lines
6.9 KiB
Markdown
33 lines
6.9 KiB
Markdown
# `createClient` configuration
|
|
|
|
| Property | Default | Description |
|
|
|--------------------------|------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
| url | | `redis[s]://[[username][:password]@][host][:port][/db-number]` (see [`redis`](https://www.iana.org/assignments/uri-schemes/prov/redis) and [`rediss`](https://www.iana.org/assignments/uri-schemes/prov/rediss) IANA registration for more details) |
|
|
| socket | | Object defining socket connection properties |
|
|
| socket.host | `'localhost'` | Hostname to connect to |
|
|
| socket.port | `6379` | Port to connect to |
|
|
| socket.path | | UNIX Socket to connect to |
|
|
| socket.connectTimeout | `5000` | The timeout for connecting to the Redis Server (in milliseconds) |
|
|
| socket.noDelay | `true` | Enable/disable the use of [`Nagle's algorithm`](https://nodejs.org/api/net.html#net_socket_setnodelay_nodelay) |
|
|
| socket.keepAlive | `5000` | Enable/disable the [`keep-alive`](https://nodejs.org/api/net.html#net_socket_setkeepalive_enable_initialdelay) functionality |
|
|
| socket.tls | | Set to `true` to enable [TLS Configuration](https://nodejs.org/api/tls.html#tls_tls_connect_options_callback) |
|
|
| socket.reconnectStrategy | `retries => Math.min(retries * 50, 500)` | A function containing the [Reconnect Strategy](#reconnect-strategy) logic |
|
|
| username | | ACL username ([see ACL guide](https://redis.io/topics/acl)) |
|
|
| password | | ACL password or the old "--requirepass" password |
|
|
| database | | Database number to connect to (see [`SELECT`](https://redis.io/commands/select) command) |
|
|
| modules | | Object defining which [Redis Modules](../../README.md#modules) to include |
|
|
| scripts | | Object defining Lua Scripts to use with this client (see [Lua Scripts](../README.md#lua-scripts)) |
|
|
| commandsQueueMaxLength | | Maximum length of the client's internal command queue |
|
|
| readonly | `false` | Connect in [`READONLY`](https://redis.io/commands/readonly) mode |
|
|
| legacyMode | `false` | Maintain some backwards compatibility (see the [Migration Guide](v3-to-v4.md)) |
|
|
| isolationPoolOptions | | See the [Isolated Execution Guide](./isolated-execution.md) |
|
|
|
|
## Reconnect Strategy
|
|
|
|
You can implement a custom reconnect strategy as a function that should:
|
|
|
|
- Receives the number of retries attempted so far.
|
|
- Should return `number | Error`:
|
|
- `number`: the time in milliseconds to wait before trying to reconnect again.
|
|
- `Error`: close the client and flush the commands queue.
|