Skip to content

Commit 0865d22

Browse files
leibalechayim
andcommittedDec 13, 2021
fix #1774 #1767 - update docs
Co-authored-by: Chayim <chayim@users.noreply.github.com>
1 parent 7110f23 commit 0865d22

File tree

2 files changed

+47
-5
lines changed

2 files changed

+47
-5
lines changed
 

‎docs/FAQ.md

+12
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,15 @@ When a socket closed unexpectedly, all the commands that were already sent will
1111
Commands are pipelined using [`queueMicrotask`](https://nodejs.org/api/globals.html#globals_queuemicrotask_callback).
1212

1313
If `socket.write()` returns `false`—meaning that ["all or part of the data was queued in user memory"](https://nodejs.org/api/net.html#net_socket_write_data_encoding_callback:~:text=all%20or%20part%20of%20the%20data%20was%20queued%20in%20user%20memory)—the commands will stack in memory until the [`drain`](https://nodejs.org/api/net.html#net_event_drain) event is fired.
14+
15+
## `RedisClientType`
16+
17+
Redis has support for [modules](https://redis.io/modules) and running [Lua scripts](../README.md#lua-scripts) within the Redis context. To take advantage of typing within these scenarios, `RedisClient` and `RedisCluster` should be used with [typeof](https://www.typescriptlang.org/docs/handbook/2/typeof-types.html), rather than the base types `RedisClientType` and `RedisClusterType`.
18+
19+
```typescript
20+
import { createClient } from '@node-redis/client';
21+
22+
export const client = createClient();
23+
24+
export type RedisClientType = typeof client;
25+
```

‎docs/client-configuration.md

+35-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
| socket.connectTimeout | `5000` | The timeout for connecting to the Redis Server (in milliseconds) |
1212
| socket.noDelay | `true` | Enable/disable the use of [`Nagle's algorithm`](https://nodejs.org/api/net.html#net_socket_setnodelay_nodelay) |
1313
| socket.keepAlive | `5000` | Enable/disable the [`keep-alive`](https://nodejs.org/api/net.html#net_socket_setkeepalive_enable_initialdelay) functionality |
14-
| socket.tls | | Set to `true` to enable [TLS Configuration](https://nodejs.org/api/tls.html#tls_tls_connect_options_callback) |
14+
| socket.tls | | See explanation and examples [below](#TLS) |
1515
| socket.reconnectStrategy | `retries => Math.min(retries * 50, 500)` | A function containing the [Reconnect Strategy](#reconnect-strategy) logic |
1616
| username | | ACL username ([see ACL guide](https://redis.io/topics/acl)) |
1717
| password | | ACL password or the old "--requirepass" password |
@@ -26,9 +26,39 @@
2626

2727
## Reconnect Strategy
2828

29-
You can implement a custom reconnect strategy as a function that should:
29+
You can implement a custom reconnect strategy as a function:
3030

3131
- Receives the number of retries attempted so far.
32-
- Should return `number | Error`:
33-
- `number`: the time in milliseconds to wait before trying to reconnect again.
34-
- `Error`: close the client and flush the commands queue.
32+
- Returns `number | Error`:
33+
- `number`: the wait time in milliseconds prior attempting to reconnect.
34+
- `Error`: closes the client and flushes the internal command queues.
35+
36+
## TLS
37+
38+
When creating a client, set `socket.tls` to `true` to enable TLS. Below are some basic examples.
39+
40+
> For configuration options see [tls.connect](https://nodejs.org/api/tls.html#tlsconnectoptions-callback) and [tls.createSecureContext](https://nodejs.org/api/tls.html#tlscreatesecurecontextoptions), as those are the underlying functions used by this library.
41+
42+
### Create a SSL client
43+
44+
```typescript
45+
createClient({
46+
socket: {
47+
tls: true,
48+
ca: '...',
49+
cert: '...'
50+
}
51+
});
52+
```
53+
54+
### Create a SSL client using a self-signed certificate
55+
56+
```typescript
57+
createClient({
58+
socket: {
59+
tls: true,
60+
rejectUnauthorized: true,
61+
cert: '...'
62+
}
63+
});
64+
```

0 commit comments

Comments
 (0)
Please sign in to comment.