redis 4.5.0 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,9 +1,8 @@
1
1
  # Node-Redis
2
2
 
3
- [![Tests](https://img.shields.io/github/workflow/status/redis/node-redis/Tests/master.svg?label=tests)](https://github.com/redis/node-redis/actions/workflows/tests.yml)
3
+ [![Tests](https://img.shields.io/github/actions/workflow/status/redis/node-redis/tests.yml?branch=master)](https://github.com/redis/node-redis/actions/workflows/tests.yml)
4
4
  [![Coverage](https://codecov.io/gh/redis/node-redis/branch/master/graph/badge.svg?token=xcfqHhJC37)](https://codecov.io/gh/redis/node-redis)
5
5
  [![License](https://img.shields.io/github/license/redis/node-redis.svg)](https://github.com/redis/node-redis/blob/master/LICENSE)
6
- [![LGTM alerts](https://img.shields.io/lgtm/alerts/g/redis/node-redis.svg?logo=LGTM)](https://lgtm.com/projects/g/redis/node-redis/alerts)
7
6
 
8
7
  [![Discord](https://img.shields.io/discord/697882427875393627.svg?style=social&logo=discord)](https://discord.gg/redis)
9
8
  [![Twitch](https://img.shields.io/twitch/status/redisinc?style=social)](https://www.twitch.tv/redisinc)
@@ -29,6 +28,14 @@ node-redis is a modern, high performance [Redis](https://redis.io) client for No
29
28
 
30
29
  ## Installation
31
30
 
31
+ Start a redis via docker:
32
+
33
+ ``` bash
34
+ docker run -p 6379:6379 -it redis/redis-stack-server:latest
35
+ ```
36
+
37
+ To install node-redis, simply:
38
+
32
39
  ```bash
33
40
  npm install redis
34
41
  ```
@@ -46,7 +53,7 @@ import { createClient } from 'redis';
46
53
 
47
54
  const client = createClient();
48
55
 
49
- client.on('error', (err) => console.log('Redis Client Error', err));
56
+ client.on('error', err => console.log('Redis Client Error', err));
50
57
 
51
58
  await client.connect();
52
59
 
@@ -65,6 +72,8 @@ createClient({
65
72
 
66
73
  You can also use discrete parameters, UNIX sockets, and even TLS to connect. Details can be found in the [client configuration guide](./docs/client-configuration.md).
67
74
 
75
+ To check if the the client is connected and ready to send commands, use `client.isReady` which returns a boolean. `client.isOpen` is also available. This returns `true` when the client's underlying socket is open, and `false` when it isn't (for example when the client is still connecting or reconnecting after a network error).
76
+
68
77
  ### Redis Commands
69
78
 
70
79
  There is built-in support for all of the [out-of-the-box Redis commands](https://redis.io/commands). They are exposed using the raw Redis command names (`HSET`, `HGETALL`, etc.) and a friendlier camel-cased version (`hSet`, `hGetAll`, etc.):
@@ -157,47 +166,7 @@ To learn more about isolated execution, check out the [guide](./docs/isolated-ex
157
166
 
158
167
  ### Pub/Sub
159
168
 
160
- Subscribing to a channel requires a dedicated stand-alone connection. You can easily get one by `.duplicate()`ing an existing Redis connection.
161
-
162
- ```typescript
163
- const subscriber = client.duplicate();
164
-
165
- await subscriber.connect();
166
- ```
167
-
168
- Once you have one, simply subscribe and unsubscribe as needed:
169
-
170
- ```typescript
171
- await subscriber.subscribe('channel', (message) => {
172
- console.log(message); // 'message'
173
- });
174
-
175
- await subscriber.pSubscribe('channe*', (message, channel) => {
176
- console.log(message, channel); // 'message', 'channel'
177
- });
178
-
179
- await subscriber.unsubscribe('channel');
180
-
181
- await subscriber.pUnsubscribe('channe*');
182
- ```
183
-
184
- Publish a message on a channel:
185
-
186
- ```typescript
187
- await publisher.publish('channel', 'message');
188
- ```
189
-
190
- There is support for buffers as well:
191
-
192
- ```typescript
193
- await subscriber.subscribe('channel', (message) => {
194
- console.log(message); // <Buffer 6d 65 73 73 61 67 65>
195
- }, true);
196
-
197
- await subscriber.pSubscribe('channe*', (message, channel) => {
198
- console.log(message, channel); // <Buffer 6d 65 73 73 61 67 65>, <Buffer 63 68 61 6e 6e 65 6c>
199
- }, true);
200
- ```
169
+ See the [Pub/Sub overview](./docs/pub-sub.md).
201
170
 
202
171
  ### Scan Iterator
203
172
 
@@ -364,15 +333,18 @@ Check out the [Clustering Guide](./docs/clustering.md) when using Node Redis to
364
333
 
365
334
  The Node Redis client class is an Nodejs EventEmitter and it emits an event each time the network status changes:
366
335
 
367
- | Event name | Scenes | Arguments to be passed to the listener |
368
- |----------------|-------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------|
369
- | `connect` | The client is initiating a connection to the server. | _No argument_ |
370
- | `ready` | The client successfully initiated the connection to the server. | _No argument_ |
371
- | `end` | The client disconnected the connection to the server via `.quit()` or `.disconnect()`. | _No argument_ |
372
- | `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]` |
373
- | `reconnecting` | The client is trying to reconnect to the server. | _No argument_ |
336
+ | Name | When | Listener arguments |
337
+ |-------------------------|------------------------------------------------------------------------------------|------------------------------------------------------------|
338
+ | `connect` | Initiating a connection to the server | *No arguments* |
339
+ | `ready` | Client is ready to use | *No arguments* |
340
+ | `end` | Connection has been closed (via `.quit()` or `.disconnect()`) | *No arguments* |
341
+ | `error` | An error has occurred—usually a network issue such as "Socket closed unexpectedly" | `(error: Error)` |
342
+ | `reconnecting` | Client is trying to reconnect to the server | *No arguments* |
343
+ | `sharded-channel-moved` | See [here](./docs/pub-sub.md#sharded-channel-moved-event) | See [here](./docs/pub-sub.md#sharded-channel-moved-event) |
344
+
345
+ > :warning: You **MUST** listen to `error` events. If a client doesn't have at least one `error` listener registered and an `error` occurs, that error will be thrown and the Node.js process will exit. See the [`EventEmitter` docs](https://nodejs.org/api/events.html#events_error_events) for more details.
374
346
 
375
- The client will not emit [any other events](./docs/v3-to-v4.md#all-the-removed-events) beyond those listed above.
347
+ > The client will not emit [any other events](./docs/v3-to-v4.md#all-the-removed-events) beyond those listed above.
376
348
 
377
349
  ## Supported Redis versions
378
350
 
package/dist/index.d.ts CHANGED
@@ -183,6 +183,8 @@ declare const modules: {
183
183
  bf: {
184
184
  ADD: typeof import("@redis/bloom/dist/commands/bloom/ADD");
185
185
  add: typeof import("@redis/bloom/dist/commands/bloom/ADD");
186
+ CARD: typeof import("@redis/bloom/dist/commands/bloom/CARD");
187
+ card: typeof import("@redis/bloom/dist/commands/bloom/CARD");
186
188
  EXISTS: typeof import("@redis/bloom/dist/commands/bloom/EXISTS");
187
189
  exists: typeof import("@redis/bloom/dist/commands/bloom/EXISTS");
188
190
  INFO: typeof import("@redis/bloom/dist/commands/bloom/INFO");
@@ -287,8 +289,8 @@ declare const modules: {
287
289
  reserve: typeof import("@redis/bloom/dist/commands/top-k/RESERVE");
288
290
  };
289
291
  };
290
- export declare type RedisDefaultModules = typeof modules;
291
- export declare type RedisClientType<M extends RedisModules = RedisDefaultModules, F extends RedisFunctions = Record<string, never>, S extends RedisScripts = Record<string, never>> = _RedisClientType<M, F, S>;
292
+ export type RedisDefaultModules = typeof modules;
293
+ export type RedisClientType<M extends RedisModules = RedisDefaultModules, F extends RedisFunctions = Record<string, never>, S extends RedisScripts = Record<string, never>> = _RedisClientType<M, F, S>;
292
294
  export declare function createClient<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts>(options?: RedisClientOptions<M, F, S>): _RedisClientType<RedisDefaultModules & M, F, S>;
293
- export declare type RedisClusterType<M extends RedisModules = RedisDefaultModules, F extends RedisFunctions = Record<string, never>, S extends RedisScripts = Record<string, never>> = _RedisClusterType<M, F, S>;
295
+ export type RedisClusterType<M extends RedisModules = RedisDefaultModules, F extends RedisFunctions = Record<string, never>, S extends RedisScripts = Record<string, never>> = _RedisClusterType<M, F, S>;
294
296
  export declare function createCluster<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts>(options: RedisClusterOptions<M, F, S>): RedisClusterType<RedisDefaultModules & M, F, S>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "redis",
3
3
  "description": "A modern, high performance Redis client",
4
- "version": "4.5.0",
4
+ "version": "4.6.0",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -23,18 +23,18 @@
23
23
  "gh-pages": "gh-pages -d ./documentation -e ./documentation -u 'documentation-bot <documentation@bot>'"
24
24
  },
25
25
  "dependencies": {
26
- "@redis/bloom": "1.1.0",
27
- "@redis/client": "1.4.0",
26
+ "@redis/bloom": "1.2.0",
27
+ "@redis/client": "1.5.0",
28
28
  "@redis/graph": "1.1.0",
29
29
  "@redis/json": "1.0.4",
30
- "@redis/search": "1.1.0",
30
+ "@redis/search": "1.1.1",
31
31
  "@redis/time-series": "1.0.4"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@tsconfig/node14": "^1.0.3",
35
- "gh-pages": "^4.0.0",
36
- "release-it": "^15.3.0",
37
- "typescript": "^4.7.4"
35
+ "gh-pages": "^5.0.0",
36
+ "release-it": "^15.6.0",
37
+ "typescript": "^4.9.4"
38
38
  },
39
39
  "repository": {
40
40
  "type": "git",
@@ -43,5 +43,8 @@
43
43
  "bugs": {
44
44
  "url": "https://github.com/redis/node-redis/issues"
45
45
  },
46
- "homepage": "https://github.com/redis/node-redis"
46
+ "homepage": "https://github.com/redis/node-redis",
47
+ "keywords": [
48
+ "redis"
49
+ ]
47
50
  }