Skip to content

Commit cf5587e

Browse files
authored
Update pub-sub.md
1 parent 5ba5e09 commit cf5587e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

docs/pub-sub.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ The Pub/Sub API is implemented by `RedisClient`, `RedisCluster`, and `RedisSenti
44

55
## Pub/Sub with `RedisClient`
66

7-
Pub/Sub requires a dedicated stand-alone client. You can easily get one by `.duplicate()`ing an existing `RedisClient`:
7+
### RESP2
8+
9+
Using RESP2, Pub/Sub "takes over" the connection (a client with subscriptions will not execute commands), therefore it requires a dedicated connection. You can easily get one by `.duplicate()`ing an existing `RedisClient`:
810

911
```javascript
1012
const subscriber = client.duplicate();
1113
subscriber.on('error', err => console.error(err));
1214
await subscriber.connect();
1315
```
1416

15-
When working with a `RedisCluster`, this is handled automatically for you.
17+
> When working with either `RedisCluster` or `RedisSentinel`, this is handled automatically for you.
1618
1719
### `sharded-channel-moved` event
1820

@@ -29,6 +31,8 @@ The event listener signature is as follows:
2931
)
3032
```
3133

34+
> When working with `RedisCluster`, this is handled automatically for you.
35+
3236
## Subscribing
3337

3438
```javascript
@@ -39,7 +43,7 @@ await client.pSubscribe('channe*', listener);
3943
await client.sSubscribe('channel', listener);
4044
```
4145

42-
> ⚠️ Subscribing to the same channel more than once will create multiple listeners which will each be called when a message is recieved.
46+
> ⚠️ Subscribing to the same channel more than once will create multiple listeners, each of which will be called when a message is received.
4347
4448
## Publishing
4549

0 commit comments

Comments
 (0)