You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
Update doctest client with latest v4 release (#2844)
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
| 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 |
|
||||
| name | | Connection name ([see `CLIENT SETNAME`](https://redis.io/commands/client-setname)) |
|
||||
| name | | Client name ([see `CLIENT SETNAME`](https://redis.io/commands/client-setname)) |
|
||||
| database | | Redis database number (see [`SELECT`](https://redis.io/commands/select) command) |
|
||||
| modules | | Included [Redis Modules](../README.md#packages) |
|
||||
| scripts | | Script definitions (see [Lua Scripts](../README.md#lua-scripts)) |
|
||||
@@ -25,16 +25,24 @@
|
||||
| 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) |
|
||||
| pingInterval | | Send `PING` command at interval (in ms). Useful with "[Azure Cache for Redis](https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-best-practices-connection#idle-timeout)" |
|
||||
| pingInterval | | Send `PING` command at interval (in ms). Useful with ["Azure Cache for Redis"](https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-best-practices-connection#idle-timeout) |
|
||||
|
||||
## Reconnect Strategy
|
||||
|
||||
You can implement a custom reconnect strategy as a function:
|
||||
When the socket closes unexpectedly (without calling `.quit()`/`.disconnect()`), the client uses `reconnectStrategy` to decide what to do. The following values are supported:
|
||||
1. `false` -> do not reconnect, close the client and flush the command queue.
|
||||
2. `number` -> wait for `X` milliseconds before reconnecting.
|
||||
3. `(retries: number, cause: Error) => false | number | Error` -> `number` is the same as configuring a `number` directly, `Error` is the same as `false`, but with a custom error.
|
||||
|
||||
- Receives the number of retries attempted so far.
|
||||
- Returns `number | Error`:
|
||||
- `number`: wait time in milliseconds prior to attempting a reconnect.
|
||||
- `Error`: closes the client and flushes internal command queues.
|
||||
By default the strategy is `Math.min(retries * 50, 500)`, but it can be overwritten like so:
|
||||
|
||||
```javascript
|
||||
createClient({
|
||||
socket: {
|
||||
reconnectStrategy: retries => Math.min(retries * 50, 1000)
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## TLS
|
||||
|
||||
@@ -44,7 +52,7 @@ To enable TLS, set `socket.tls` to `true`. Below are some basic examples.
|
||||
|
||||
### Create a SSL client
|
||||
|
||||
```typescript
|
||||
```javascript
|
||||
createClient({
|
||||
socket: {
|
||||
tls: true,
|
||||
@@ -56,7 +64,7 @@ createClient({
|
||||
|
||||
### Create a SSL client using a self-signed certificate
|
||||
|
||||
```typescript
|
||||
```javascript
|
||||
createClient({
|
||||
socket: {
|
||||
tls: true,
|
||||
|
Reference in New Issue
Block a user