ioredis 4.27.6 → 4.27.7
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/Changelog.md +7 -0
- package/README.md +1 -1
- package/built/autoPipelining.js +30 -1
- package/built/utils/lodash.js +2 -0
- package/package.json +3 -1
package/Changelog.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [4.27.7](https://github.com/luin/ioredis/compare/v4.27.6...v4.27.7) (2021-08-01)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **cluster:** fix autopipeline with keyPrefix or arg array ([#1391](https://github.com/luin/ioredis/issues/1391)) ([d7477aa](https://github.com/luin/ioredis/commit/d7477aa5853388b51037210542372131919ddfb2)), closes [#1264](https://github.com/luin/ioredis/issues/1264) [#1248](https://github.com/luin/ioredis/issues/1248) [#1392](https://github.com/luin/ioredis/issues/1392)
|
|
7
|
+
|
|
1
8
|
## [4.27.6](https://github.com/luin/ioredis/compare/v4.27.5...v4.27.6) (2021-06-13)
|
|
2
9
|
|
|
3
10
|
|
package/README.md
CHANGED
|
@@ -755,7 +755,7 @@ const redis = new Redis({
|
|
|
755
755
|
|
|
756
756
|
This feature is useful when using Amazon ElastiCache instances with Auto-failover disabled. On these instances, test your `reconnectOnError` handler by manually promoting the replica node to the primary role using the AWS console. The following writes fail with the error `READONLY`. Using `reconnectOnError`, we can force the connection to reconnect on this error in order to connect to the new master. Furthermore, if the `reconnectOnError` returns `2`, ioredis will resend the failed command after reconnecting.
|
|
757
757
|
|
|
758
|
-
On ElastiCache
|
|
758
|
+
On ElastiCache instances with Auto-failover enabled, `reconnectOnError` does not execute. Instead of returning a Redis error, AWS closes all connections to the master endpoint until the new primary node is ready. ioredis reconnects via `retryStrategy` instead of `reconnectOnError` after about a minute. On ElastiCache instances with Auto-failover enabled, test failover events with the `Failover primary` option in the AWS console.
|
|
759
759
|
|
|
760
760
|
## Connection Events
|
|
761
761
|
|
package/built/autoPipelining.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const PromiseContainer = require("./promiseContainer");
|
|
4
|
+
const lodash_1 = require("./utils/lodash");
|
|
4
5
|
const calculateSlot = require("cluster-key-slot");
|
|
5
6
|
const standard_as_callback_1 = require("standard-as-callback");
|
|
6
7
|
exports.kExec = Symbol("exec");
|
|
@@ -62,6 +63,29 @@ function shouldUseAutoPipelining(client, functionName, commandName) {
|
|
|
62
63
|
!client.options.autoPipeliningIgnoredCommands.includes(commandName));
|
|
63
64
|
}
|
|
64
65
|
exports.shouldUseAutoPipelining = shouldUseAutoPipelining;
|
|
66
|
+
/**
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
function getFirstValueInFlattenedArray(args) {
|
|
70
|
+
for (let i = 0; i < args.length; i++) {
|
|
71
|
+
const arg = args[i];
|
|
72
|
+
if (typeof arg === "string") {
|
|
73
|
+
return arg;
|
|
74
|
+
}
|
|
75
|
+
else if (Array.isArray(arg) || lodash_1.isArguments(arg)) {
|
|
76
|
+
if (arg.length === 0) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
return arg[0];
|
|
80
|
+
}
|
|
81
|
+
const flattened = lodash_1.flatten([arg]);
|
|
82
|
+
if (flattened.length > 0) {
|
|
83
|
+
return flattened[0];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
exports.getFirstValueInFlattenedArray = getFirstValueInFlattenedArray;
|
|
65
89
|
function executeWithAutoPipelining(client, functionName, commandName, args, callback) {
|
|
66
90
|
const CustomPromise = PromiseContainer.get();
|
|
67
91
|
// On cluster mode let's wait for slots to be available
|
|
@@ -77,7 +101,12 @@ function executeWithAutoPipelining(client, functionName, commandName, args, call
|
|
|
77
101
|
});
|
|
78
102
|
}
|
|
79
103
|
// If we have slot information, we can improve routing by grouping slots served by the same subset of nodes
|
|
80
|
-
|
|
104
|
+
// Note that the first value in args may be a (possibly empty) array.
|
|
105
|
+
// ioredis will only flatten one level of the array, in the Command constructor.
|
|
106
|
+
const prefix = client.options.keyPrefix || "";
|
|
107
|
+
const slotKey = client.isCluster
|
|
108
|
+
? client.slots[calculateSlot(`${prefix}${getFirstValueInFlattenedArray(args)}`)].join(",")
|
|
109
|
+
: "main";
|
|
81
110
|
if (!client._autoPipelines.has(slotKey)) {
|
|
82
111
|
const pipeline = client.pipeline();
|
|
83
112
|
pipeline[exports.kExec] = false;
|
package/built/utils/lodash.js
CHANGED
|
@@ -4,5 +4,7 @@ const defaults = require("lodash.defaults");
|
|
|
4
4
|
exports.defaults = defaults;
|
|
5
5
|
const flatten = require("lodash.flatten");
|
|
6
6
|
exports.flatten = flatten;
|
|
7
|
+
const isArguments = require("lodash.isarguments");
|
|
8
|
+
exports.isArguments = isArguments;
|
|
7
9
|
function noop() { }
|
|
8
10
|
exports.noop = noop;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ioredis",
|
|
3
|
-
"version": "4.27.
|
|
3
|
+
"version": "4.27.7",
|
|
4
4
|
"description": "A robust, performance-focused and full-featured Redis client for Node.js.",
|
|
5
5
|
"main": "built/index.js",
|
|
6
6
|
"files": [
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"denque": "^1.1.0",
|
|
39
39
|
"lodash.defaults": "^4.2.0",
|
|
40
40
|
"lodash.flatten": "^4.4.0",
|
|
41
|
+
"lodash.isarguments": "^3.1.0",
|
|
41
42
|
"p-map": "^2.1.0",
|
|
42
43
|
"redis-commands": "1.7.0",
|
|
43
44
|
"redis-errors": "^1.2.0",
|
|
@@ -53,6 +54,7 @@
|
|
|
53
54
|
"@types/debug": "^4.1.5",
|
|
54
55
|
"@types/lodash.defaults": "^4.2.6",
|
|
55
56
|
"@types/lodash.flatten": "^4.4.6",
|
|
57
|
+
"@types/lodash.isarguments": "^3.1.6",
|
|
56
58
|
"@types/mocha": "^7.0.2",
|
|
57
59
|
"@types/node": "^13.11.0",
|
|
58
60
|
"@types/redis-errors": "1.2.0",
|