Skip to content

Commit b6cb1b1

Browse files
authored
Add the event doc (#1753)
1 parent 41bd136 commit b6cb1b1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,20 @@ await Promise.all([
277277

278278
Check out the [Clustering Guide](./docs/clustering.md) when using Node Redis to connect to a Redis Cluster.
279279

280+
### Events
281+
282+
The Node Redis client class is an Nodejs EventEmitter and it emits an event each time the network status changes:
283+
284+
| Event name | Scenes | Parameters |
285+
|--------------|-------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|
286+
| connect | The client is initiating a connection to the server. | _undefined_ |
287+
| ready | The client successfully initiated the connection to the server. | _undefined_ |
288+
| end | The client disconnected the connection to the server via `.quit()` or `.disconnect()`. | _undefined_ |
289+
| error | When a network error has occurred, such as unable to connect to the server or the connection closed unexpectedly. | The error object, such as `SocketClosedUnexpectedlyError: Socket closed unexpectedly` or `Error: connect ECONNREFUSED [IP]:[PORT]` |
290+
| reconnecting | The client is trying to reconnect to the server. | _undefined_ |
291+
292+
The client will not emit any other events beyond those listed above.
293+
280294
## Supported Redis versions
281295

282296
Node Redis is supported with the following versions of Redis:

0 commit comments

Comments
 (0)