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 +24 -52
- package/dist/index.d.ts +5 -3
- package/package.json +11 -8
package/README.md
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
# Node-Redis
|
|
2
2
|
|
|
3
|
-
[](https://github.com/redis/node-redis/actions/workflows/tests.yml)
|
|
4
4
|
[](https://codecov.io/gh/redis/node-redis)
|
|
5
5
|
[](https://github.com/redis/node-redis/blob/master/LICENSE)
|
|
6
|
-
[](https://lgtm.com/projects/g/redis/node-redis/alerts)
|
|
7
6
|
|
|
8
7
|
[](https://discord.gg/redis)
|
|
9
8
|
[](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',
|
|
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
|
-
|
|
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
|
-
|
|
|
368
|
-
|
|
369
|
-
| `connect`
|
|
370
|
-
| `ready`
|
|
371
|
-
| `end`
|
|
372
|
-
| `error`
|
|
373
|
-
| `reconnecting`
|
|
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
|
|
291
|
-
export
|
|
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
|
|
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.
|
|
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.
|
|
27
|
-
"@redis/client": "1.
|
|
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.
|
|
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": "^
|
|
36
|
-
"release-it": "^15.
|
|
37
|
-
"typescript": "^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
|
}
|