redis 4.0.0 → 4.0.1
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 +26 -10
- package/dist/index.d.ts +7 -2
- package/package.json +19 -7
- package/.idea/modules.xml +0 -8
- package/.idea/node-redis.iml +0 -12
- package/.idea/vcs.xml +0 -6
- package/dump.rdb +0 -0
- package/scripts/cluster-stress-test.js +0 -72
- package/scripts/error.log +0 -0
- package/scripts/node_modules/.package-lock.json +0 -28
- package/scripts/package-lock.json +0 -47
- package/scripts/package.json +0 -9
package/README.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# Node-Redis
|
|
2
2
|
|
|
3
|
-
[](https://
|
|
3
|
+
[](https://github.com/redis/node-redis/actions/workflows/tests.yml)
|
|
4
4
|
[](https://codecov.io/gh/redis/node-redis)
|
|
5
|
-
[](https://
|
|
6
|
-
[](https://github.com/redis/node-redis/blob/master/LICENSE)
|
|
6
|
+
[](https://lgtm.com/projects/g/redis/node-redis/alerts)
|
|
7
|
+
[](https://discord.gg/redis)
|
|
7
8
|
|
|
8
9
|
node-redis is a modern, high performance [Redis](https://redis.io) client for Node.js with built-in support for Redis 6.2 commands and modules including [RediSearch](https://redisearch.io) and [RedisJSON](https://redisjson.io).
|
|
9
10
|
|
|
@@ -180,7 +181,7 @@ This works with `HSCAN`, `SSCAN`, and `ZSCAN` too:
|
|
|
180
181
|
```typescript
|
|
181
182
|
for await (const { field, value } of client.hScanIterator('hash')) {}
|
|
182
183
|
for await (const member of client.sScanIterator('set')) {}
|
|
183
|
-
for await (const { score,
|
|
184
|
+
for await (const { score, value } of client.zScanIterator('sorted-set')) {}
|
|
184
185
|
```
|
|
185
186
|
|
|
186
187
|
You can override the default options by providing a configuration object:
|
|
@@ -277,6 +278,20 @@ await Promise.all([
|
|
|
277
278
|
|
|
278
279
|
Check out the [Clustering Guide](./docs/clustering.md) when using Node Redis to connect to a Redis Cluster.
|
|
279
280
|
|
|
281
|
+
### Events
|
|
282
|
+
|
|
283
|
+
The Node Redis client class is an Nodejs EventEmitter and it emits an event each time the network status changes:
|
|
284
|
+
|
|
285
|
+
| Event name | Scenes | Parameters |
|
|
286
|
+
|--------------|-------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|
|
|
287
|
+
| connect | The client is initiating a connection to the server. | _undefined_ |
|
|
288
|
+
| ready | The client successfully initiated the connection to the server. | _undefined_ |
|
|
289
|
+
| end | The client disconnected the connection to the server via `.quit()` or `.disconnect()`. | _undefined_ |
|
|
290
|
+
| 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]` |
|
|
291
|
+
| reconnecting | The client is trying to reconnect to the server. | _undefined_ |
|
|
292
|
+
|
|
293
|
+
The client will not emit any other events beyond those listed above.
|
|
294
|
+
|
|
280
295
|
## Supported Redis versions
|
|
281
296
|
|
|
282
297
|
Node Redis is supported with the following versions of Redis:
|
|
@@ -292,12 +307,13 @@ Node Redis is supported with the following versions of Redis:
|
|
|
292
307
|
|
|
293
308
|
## Packages
|
|
294
309
|
|
|
295
|
-
|
|
|
296
|
-
|
|
297
|
-
| [redis](./)
|
|
298
|
-
| [@node-redis/client](./packages/client)
|
|
299
|
-
| [@node-redis/json](./packages/json)
|
|
300
|
-
| [@node-redis/search](./packages/search)
|
|
310
|
+
| ----------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
311
|
+
|---------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
312
|
+
| [redis](./) | [](https://www.npmjs.com/package/redis) [](https://www.npmjs.com/package/redis) |
|
|
313
|
+
| [@node-redis/client](./packages/client) | [](https://www.npmjs.com/package/@node-redis/client) [](https://www.npmjs.com/package/@node-redis/client) [](https://redis.js.org/documentation/client/) |
|
|
314
|
+
| [@node-redis/json](./packages/json) | [](https://www.npmjs.com/package/@node-redis/json) [](https://www.npmjs.com/package/@node-redis/json) [](https://redis.js.org/documentation/json/) [Redis JSON](https://oss.redis.com/redisjson/) commands |
|
|
315
|
+
| [@node-redis/search](./packages/search) | [](https://www.npmjs.com/package/@node-redis/search) [](https://www.npmjs.com/package/@node-redis/search) [](https://redis.js.org/documentation/search/) [Redis Search](https://oss.redis.com/redisearch/) commands |
|
|
316
|
+
| [@node-redis/time-series](./packages/time-series) | [](https://www.npmjs.com/package/@node-redis/time-series) [](https://www.npmjs.com/package/@node-redis/time-series) [](https://redis.js.org/documentation/time-series/) [Redis Time-Series](https://oss.redis.com/redistimeseries/) commands |
|
|
301
317
|
|
|
302
318
|
## Contributing
|
|
303
319
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
+
import { RedisClientOptions, RedisClientType, RedisClusterOptions, RedisClusterType } from '@node-redis/client';
|
|
1
2
|
import { RedisScripts } from '@node-redis/client/dist/lib/commands';
|
|
2
|
-
import { RedisClientOptions, RedisClientType } from '@node-redis/client/dist/lib/client';
|
|
3
|
-
import { RedisClusterOptions, RedisClusterType } from '@node-redis/client/dist/lib/cluster';
|
|
4
3
|
export * from '@node-redis/client';
|
|
5
4
|
export * from '@node-redis/json';
|
|
6
5
|
export * from '@node-redis/search';
|
|
@@ -50,6 +49,8 @@ declare const modules: {
|
|
|
50
49
|
ft: {
|
|
51
50
|
_LIST: typeof import("@node-redis/search/dist/commands/_LIST");
|
|
52
51
|
_list: typeof import("@node-redis/search/dist/commands/_LIST");
|
|
52
|
+
ALTER: typeof import("@node-redis/search/dist/commands/ALTER");
|
|
53
|
+
alter: typeof import("@node-redis/search/dist/commands/ALTER");
|
|
53
54
|
AGGREGATE: typeof import("@node-redis/search/dist/commands/AGGREGATE");
|
|
54
55
|
aggregate: typeof import("@node-redis/search/dist/commands/AGGREGATE");
|
|
55
56
|
ALIASADD: typeof import("@node-redis/search/dist/commands/ALIASADD");
|
|
@@ -78,6 +79,10 @@ declare const modules: {
|
|
|
78
79
|
explainCli: typeof import("@node-redis/search/dist/commands/EXPLAINCLI");
|
|
79
80
|
INFO: typeof import("@node-redis/search/dist/commands/INFO");
|
|
80
81
|
info: typeof import("@node-redis/search/dist/commands/INFO");
|
|
82
|
+
PROFILESEARCH: typeof import("@node-redis/search/dist/commands/PROFILE_SEARCH");
|
|
83
|
+
profileSearch: typeof import("@node-redis/search/dist/commands/PROFILE_SEARCH");
|
|
84
|
+
PROFILEAGGREGATE: typeof import("@node-redis/search/dist/commands/PROFILE_AGGREGATE");
|
|
85
|
+
profileAggregate: typeof import("@node-redis/search/dist/commands/PROFILE_AGGREGATE");
|
|
81
86
|
SEARCH: typeof import("@node-redis/search/dist/commands/SEARCH");
|
|
82
87
|
search: typeof import("@node-redis/search/dist/commands/SEARCH");
|
|
83
88
|
SPELLCHECK: typeof import("@node-redis/search/dist/commands/SPELLCHECK");
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redis",
|
|
3
|
-
"
|
|
3
|
+
"description": "A modern, high performance Redis client",
|
|
4
|
+
"version": "4.0.1",
|
|
4
5
|
"license": "MIT",
|
|
5
6
|
"main": "./dist/index.js",
|
|
6
7
|
"types": "./dist/index.d.ts",
|
|
@@ -14,17 +15,22 @@
|
|
|
14
15
|
"build:tests-tools": "npm run build:client && npm run build:test-utils",
|
|
15
16
|
"build:modules": "find ./packages -mindepth 1 -maxdepth 1 -type d ! -name 'client' ! -name 'test-utils' -exec npm run build -w {} \\;",
|
|
16
17
|
"build": "tsc",
|
|
17
|
-
"build-all": "npm run build:client && npm run build:test-utils && npm run build:modules && npm run build"
|
|
18
|
+
"build-all": "npm run build:client && npm run build:test-utils && npm run build:modules && npm run build",
|
|
19
|
+
"documentation": "npm run documentation -ws --if-present",
|
|
20
|
+
"gh-pages": "gh-pages -d ./documentation -e ./documentation -u 'documentation-bot <documentation@bot>'"
|
|
18
21
|
},
|
|
19
22
|
"dependencies": {
|
|
20
|
-
"@node-redis/client": "^1.0.
|
|
21
|
-
"@node-redis/json": "^1.0.
|
|
22
|
-
"@node-redis/search": "^1.0.
|
|
23
|
+
"@node-redis/client": "^1.0.1",
|
|
24
|
+
"@node-redis/json": "^1.0.1",
|
|
25
|
+
"@node-redis/search": "^1.0.1",
|
|
26
|
+
"@node-redis/time-series": "^1.0.0"
|
|
23
27
|
},
|
|
24
28
|
"devDependencies": {
|
|
25
29
|
"@tsconfig/node12": "^1.0.9",
|
|
30
|
+
"gh-pages": "^3.2.3",
|
|
26
31
|
"release-it": "^14.11.8",
|
|
27
|
-
"
|
|
32
|
+
"typedoc": "^0.22.10",
|
|
33
|
+
"typescript": "^4.5.3"
|
|
28
34
|
},
|
|
29
35
|
"repository": {
|
|
30
36
|
"type": "git",
|
|
@@ -33,5 +39,11 @@
|
|
|
33
39
|
"bugs": {
|
|
34
40
|
"url": "https://github.com/redis/node-redis/issues"
|
|
35
41
|
},
|
|
36
|
-
"homepage": "https://github.com/redis/node-redis"
|
|
42
|
+
"homepage": "https://github.com/redis/node-redis",
|
|
43
|
+
"files": [
|
|
44
|
+
"dist/"
|
|
45
|
+
],
|
|
46
|
+
"engines": {
|
|
47
|
+
"npm": ">=7"
|
|
48
|
+
}
|
|
37
49
|
}
|
package/.idea/modules.xml
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="ProjectModuleManager">
|
|
4
|
-
<modules>
|
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/node-redis.iml" filepath="$PROJECT_DIR$/.idea/node-redis.iml" />
|
|
6
|
-
</modules>
|
|
7
|
-
</component>
|
|
8
|
-
</project>
|
package/.idea/node-redis.iml
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="WEB_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager">
|
|
4
|
-
<content url="file://$MODULE_DIR$">
|
|
5
|
-
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
6
|
-
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
7
|
-
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
-
</content>
|
|
9
|
-
<orderEntry type="inheritedJdk" />
|
|
10
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
-
</component>
|
|
12
|
-
</module>
|
package/.idea/vcs.xml
DELETED
package/dump.rdb
DELETED
|
Binary file
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { createCluster } from 'redis';
|
|
2
|
-
import { strict as assert } from 'assert';
|
|
3
|
-
import { promises as fs } from 'fs';
|
|
4
|
-
|
|
5
|
-
const cluster = createCluster({
|
|
6
|
-
rootNodes: [{
|
|
7
|
-
socket: {
|
|
8
|
-
host: 'redis-14416.ned.shahar.demo.redislabs.com',
|
|
9
|
-
port: 14416
|
|
10
|
-
}
|
|
11
|
-
}],
|
|
12
|
-
defaults: {
|
|
13
|
-
password: 'osscluster'
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
cluster.on('error', err => console.error('Redis Cluster Error', err));
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
await cluster.connect();
|
|
21
|
-
|
|
22
|
-
await Promise.all([
|
|
23
|
-
...cluster.getMasters().map(({ client }) => client.flushAll()),
|
|
24
|
-
fs.writeFile('./error.log', '')
|
|
25
|
-
]);
|
|
26
|
-
|
|
27
|
-
await promiseConcurrency(setAndGet, { end: 500000, concurrency: 1000 });
|
|
28
|
-
} finally {
|
|
29
|
-
await cluster.disconnect();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async function setAndGet(i) {
|
|
33
|
-
const str = i.toString();
|
|
34
|
-
|
|
35
|
-
await cluster.set(str, str);
|
|
36
|
-
|
|
37
|
-
assert.equal(
|
|
38
|
-
await cluster.get(str),
|
|
39
|
-
str
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function promiseConcurrency(fn, { start = 0, end, concurrency }) {
|
|
44
|
-
return new Promise(resolve => {
|
|
45
|
-
let num = start,
|
|
46
|
-
inProgress = 0;
|
|
47
|
-
|
|
48
|
-
function run() {
|
|
49
|
-
++inProgress;
|
|
50
|
-
|
|
51
|
-
const i = num++;
|
|
52
|
-
if (i % 1000 === 0) {
|
|
53
|
-
console.log('!!!', i);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
fn(i)
|
|
57
|
-
.finally(() => --inProgress)
|
|
58
|
-
.then(() => {
|
|
59
|
-
if (num < end) {
|
|
60
|
-
run();
|
|
61
|
-
} else if (inProgress === 0) {
|
|
62
|
-
resolve();
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
.catch(err => fs.appendFile('./error.log', `${i.toString()} - ${err.toString()}\n\n-------\n\n`));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
for (let i = 0; i < concurrency; i++) {
|
|
69
|
-
run();
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
package/scripts/error.log
DELETED
|
File without changes
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "node-redis-scripts",
|
|
3
|
-
"lockfileVersion": 2,
|
|
4
|
-
"requires": true,
|
|
5
|
-
"packages": {
|
|
6
|
-
"..": {
|
|
7
|
-
"version": "4.0.0-rc.4",
|
|
8
|
-
"license": "MIT",
|
|
9
|
-
"workspaces": [
|
|
10
|
-
"./packages/*"
|
|
11
|
-
],
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"@node-redis/client": "^1.0.0-rc.0",
|
|
14
|
-
"@node-redis/json": "^1.0.0-rc.0",
|
|
15
|
-
"@node-redis/search": "^1.0.0-rc.0"
|
|
16
|
-
},
|
|
17
|
-
"devDependencies": {
|
|
18
|
-
"@tsconfig/node12": "^1.0.9",
|
|
19
|
-
"release-it": "^14.11.7",
|
|
20
|
-
"typescript": "^4.4.4"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"node_modules/redis": {
|
|
24
|
-
"resolved": "..",
|
|
25
|
-
"link": true
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "node-redis-scripts",
|
|
3
|
-
"lockfileVersion": 2,
|
|
4
|
-
"requires": true,
|
|
5
|
-
"packages": {
|
|
6
|
-
"": {
|
|
7
|
-
"name": "node-redis-scripts",
|
|
8
|
-
"dependencies": {
|
|
9
|
-
"redis": "../"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
"..": {
|
|
13
|
-
"version": "4.0.0-rc.4",
|
|
14
|
-
"license": "MIT",
|
|
15
|
-
"workspaces": [
|
|
16
|
-
"./packages/*"
|
|
17
|
-
],
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"@node-redis/client": "^1.0.0-rc.0",
|
|
20
|
-
"@node-redis/json": "^1.0.0-rc.0",
|
|
21
|
-
"@node-redis/search": "^1.0.0-rc.0"
|
|
22
|
-
},
|
|
23
|
-
"devDependencies": {
|
|
24
|
-
"@tsconfig/node12": "^1.0.9",
|
|
25
|
-
"release-it": "^14.11.7",
|
|
26
|
-
"typescript": "^4.4.4"
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
"node_modules/redis": {
|
|
30
|
-
"resolved": "..",
|
|
31
|
-
"link": true
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
"dependencies": {
|
|
35
|
-
"redis": {
|
|
36
|
-
"version": "file:..",
|
|
37
|
-
"requires": {
|
|
38
|
-
"@node-redis/client": "^1.0.0-rc.0",
|
|
39
|
-
"@node-redis/json": "^1.0.0-rc.0",
|
|
40
|
-
"@node-redis/search": "^1.0.0-rc.0",
|
|
41
|
-
"@tsconfig/node12": "^1.0.9",
|
|
42
|
-
"release-it": "^14.11.7",
|
|
43
|
-
"typescript": "^4.4.4"
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|