You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
Add the list of removed events to migration guide (#1761)
* Update v3-to-v4.md * Update README.md * Correct the wrong description * Update docs/v3-to-v4.md Co-authored-by: Simon Prickett <simon@crudworks.org> * Update docs/v3-to-v4.md Co-authored-by: Simon Prickett <simon@crudworks.org> Co-authored-by: Simon Prickett <simon@crudworks.org>
This commit is contained in:
16
README.md
16
README.md
@@ -296,15 +296,15 @@ Check out the [Clustering Guide](./docs/clustering.md) when using Node Redis to
|
|||||||
|
|
||||||
The Node Redis client class is an Nodejs EventEmitter and it emits an event each time the network status changes:
|
The Node Redis client class is an Nodejs EventEmitter and it emits an event each time the network status changes:
|
||||||
|
|
||||||
| Event name | Scenes | Parameters |
|
| Event name | Scenes | Arguments to be passed to the listener |
|
||||||
|--------------|-------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|
|
|----------------|-------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| connect | The client is initiating a connection to the server. | _undefined_ |
|
| `connect` | The client is initiating a connection to the server. | _No argument_ |
|
||||||
| ready | The client successfully initiated the connection to the server. | _undefined_ |
|
| `ready` | The client successfully initiated the connection to the server. | _No argument_ |
|
||||||
| end | The client disconnected the connection to the server via `.quit()` or `.disconnect()`. | _undefined_ |
|
| `end` | The client disconnected the connection to the server via `.quit()` or `.disconnect()`. | _No argument_ |
|
||||||
| 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]` |
|
| `error` | When a network error has occurred, such as unable to connect to the server or the connection closed unexpectedly. | 1 argument: The error object, such as `SocketClosedUnexpectedlyError: Socket closed unexpectedly` or `Error: connect ECONNREFUSED [IP]:[PORT]` |
|
||||||
| reconnecting | The client is trying to reconnect to the server. | _undefined_ |
|
| `reconnecting` | The client is trying to reconnect to the server. | _No argument_ |
|
||||||
|
|
||||||
The client will not emit any other events beyond those listed above.
|
The client will not emit [any other events](./docs/v3-to-v4.md#all-the-removed-events) beyond those listed above.
|
||||||
|
|
||||||
## Supported Redis versions
|
## Supported Redis versions
|
||||||
|
|
||||||
|
@@ -28,15 +28,31 @@ await client.connect();
|
|||||||
await client.ping();
|
await client.ping();
|
||||||
```
|
```
|
||||||
|
|
||||||
### No `message` event
|
### All the removed events
|
||||||
|
|
||||||
In V4, you don't need to add listener to the `message` and `message_buffer` events, you can get the message directly in `subscribe`-like commands.
|
The following events that existed in V3 were removed in V4:
|
||||||
|
|
||||||
|
1. `warning`
|
||||||
|
2. `subscribe`
|
||||||
|
3. `psubscribe`
|
||||||
|
4. `unsubscribe`
|
||||||
|
5. `message`
|
||||||
|
6. `message_buffer`
|
||||||
|
7. `messageBuffer`
|
||||||
|
8. `pmessage`
|
||||||
|
9. `pmessage_buffer`
|
||||||
|
10. `pmessageBuffer`
|
||||||
|
11. `monitor`
|
||||||
|
|
||||||
|
#### No `message`-like event
|
||||||
|
|
||||||
|
In V4, you don't need to add a listener to the `message`-like events (items 5 to 10 of the above list), you can get the message directly in `subscribe`-like commands.
|
||||||
|
|
||||||
The second argument of these commands is a callback, which will be triggered every time there is a message published to the channel.
|
The second argument of these commands is a callback, which will be triggered every time there is a message published to the channel.
|
||||||
|
|
||||||
The third argument to these commands is a boolean to set `bufferMode` (default `false`). If it's set to `true` you will receive a buffer instead of a string.
|
The third argument to these commands is a boolean to set `bufferMode` (default `false`). If it's set to `true` you will receive a buffer instead of a string.
|
||||||
|
|
||||||
The `subscribe`-like commands return a promise. If the server returns `ok` the promise will be fulfilled, otherwise the promise will be rejected.
|
The `subscribe`-like commands return a promise. If the command is executed successfully the promise will be fulfilled, otherwise the promise will be rejected.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { createClient } from 'redis';
|
import { createClient } from 'redis';
|
||||||
|
Reference in New Issue
Block a user