ioredis 4.27.5 → 4.27.6
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/built/autoPipelining.js +2 -8
- package/built/cluster/index.js +19 -0
- package/built/pipeline.js +3 -3
- package/built/redis/index.js +2 -0
- package/package.json +1 -1
package/Changelog.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [4.27.6](https://github.com/luin/ioredis/compare/v4.27.5...v4.27.6) (2021-06-13)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* fixed autopipeline performances. ([#1226](https://github.com/luin/ioredis/issues/1226)) ([42f1ee1](https://github.com/luin/ioredis/commit/42f1ee107174366a79ff94bec8a7a1ac353e035c))
|
|
7
|
+
|
|
1
8
|
## [4.27.5](https://github.com/luin/ioredis/compare/v4.27.4...v4.27.5) (2021-06-05)
|
|
2
9
|
|
|
3
10
|
|
package/built/autoPipelining.js
CHANGED
|
@@ -18,13 +18,6 @@ exports.notAllowedAutoPipelineCommands = [
|
|
|
18
18
|
"unsubscribe",
|
|
19
19
|
"unpsubscribe",
|
|
20
20
|
];
|
|
21
|
-
function findAutoPipeline(client, _commandName, ...args) {
|
|
22
|
-
if (!client.isCluster) {
|
|
23
|
-
return "main";
|
|
24
|
-
}
|
|
25
|
-
// We have slot information, we can improve routing by grouping slots served by the same subset of nodes
|
|
26
|
-
return client.slots[calculateSlot(args[0])].join(",");
|
|
27
|
-
}
|
|
28
21
|
function executeAutoPipeline(client, slotKey) {
|
|
29
22
|
/*
|
|
30
23
|
If a pipeline is already executing, keep queueing up commands
|
|
@@ -83,7 +76,8 @@ function executeWithAutoPipelining(client, functionName, commandName, args, call
|
|
|
83
76
|
});
|
|
84
77
|
});
|
|
85
78
|
}
|
|
86
|
-
|
|
79
|
+
// If we have slot information, we can improve routing by grouping slots served by the same subset of nodes
|
|
80
|
+
const slotKey = client.isCluster ? client.slots[calculateSlot(args[0])].join(",") : 'main';
|
|
87
81
|
if (!client._autoPipelines.has(slotKey)) {
|
|
88
82
|
const pipeline = client.pipeline();
|
|
89
83
|
pipeline[exports.kExec] = false;
|
package/built/cluster/index.js
CHANGED
|
@@ -42,6 +42,8 @@ class Cluster extends events_1.EventEmitter {
|
|
|
42
42
|
this.isRefreshing = false;
|
|
43
43
|
this.isCluster = true;
|
|
44
44
|
this._autoPipelines = new Map();
|
|
45
|
+
this._groupsIds = {};
|
|
46
|
+
this._groupsBySlot = Array(16384);
|
|
45
47
|
this._runningAutoPipelines = new Set();
|
|
46
48
|
this._readyDelayedCallbacks = [];
|
|
47
49
|
this._addedScriptHashes = {};
|
|
@@ -127,7 +129,9 @@ class Cluster extends events_1.EventEmitter {
|
|
|
127
129
|
reject(new Error("Redis is already connecting/connected"));
|
|
128
130
|
return;
|
|
129
131
|
}
|
|
132
|
+
// Make sure only one timer is active at a time
|
|
130
133
|
clearInterval(this._addedScriptHashesCleanInterval);
|
|
134
|
+
// Start the script cache cleaning
|
|
131
135
|
this._addedScriptHashesCleanInterval = setInterval(() => {
|
|
132
136
|
this._addedScriptHashes = {};
|
|
133
137
|
}, this.options.maxScriptsCachingTime);
|
|
@@ -491,6 +495,7 @@ class Cluster extends events_1.EventEmitter {
|
|
|
491
495
|
else {
|
|
492
496
|
_this.slots[slot] = [key];
|
|
493
497
|
}
|
|
498
|
+
_this._groupsBySlot[slot] = _this._groupsIds[_this.slots[slot].join(';')];
|
|
494
499
|
_this.connectionPool.findOrCreate(_this.natMapper(key));
|
|
495
500
|
tryConnection();
|
|
496
501
|
debug("refreshing slot caches... (triggered by MOVED error)");
|
|
@@ -693,6 +698,20 @@ class Cluster extends events_1.EventEmitter {
|
|
|
693
698
|
this.slots[slot] = keys;
|
|
694
699
|
}
|
|
695
700
|
}
|
|
701
|
+
// Assign to each node keys a numeric value to make autopipeline comparison faster.
|
|
702
|
+
this._groupsIds = Object.create(null);
|
|
703
|
+
let j = 0;
|
|
704
|
+
for (let i = 0; i < 16384; i++) {
|
|
705
|
+
const target = (this.slots[i] || []).join(';');
|
|
706
|
+
if (!target.length) {
|
|
707
|
+
this._groupsBySlot[i] = undefined;
|
|
708
|
+
continue;
|
|
709
|
+
}
|
|
710
|
+
if (!this._groupsIds[target]) {
|
|
711
|
+
this._groupsIds[target] = ++j;
|
|
712
|
+
}
|
|
713
|
+
this._groupsBySlot[i] = this._groupsIds[target];
|
|
714
|
+
}
|
|
696
715
|
this.connectionPool.reset(nodes);
|
|
697
716
|
callback();
|
|
698
717
|
}, this.options.slotsRefreshTimeout));
|
package/built/pipeline.js
CHANGED
|
@@ -15,10 +15,9 @@ const commander_1 = require("./commander");
|
|
|
15
15
|
*/
|
|
16
16
|
function generateMultiWithNodes(redis, keys) {
|
|
17
17
|
const slot = calculateSlot(keys[0]);
|
|
18
|
-
const target = redis.
|
|
18
|
+
const target = redis._groupsBySlot[slot];
|
|
19
19
|
for (let i = 1; i < keys.length; i++) {
|
|
20
|
-
|
|
21
|
-
if (currentTarget !== target) {
|
|
20
|
+
if (redis._groupsBySlot[calculateSlot(keys[i])] !== target) {
|
|
22
21
|
return -1;
|
|
23
22
|
}
|
|
24
23
|
}
|
|
@@ -141,6 +140,7 @@ Pipeline.prototype.fillResult = function (value, position) {
|
|
|
141
140
|
moved: function (slot, key) {
|
|
142
141
|
_this.preferKey = key;
|
|
143
142
|
_this.redis.slots[errv[1]] = [key];
|
|
143
|
+
_this.redis._groupsBySlot[errv[1]] = _this.redis._groupsIds[_this.redis.slots[errv[1]].join(";")];
|
|
144
144
|
_this.redis.refreshSlotsCache();
|
|
145
145
|
_this.exec();
|
|
146
146
|
},
|
package/built/redis/index.js
CHANGED
|
@@ -262,7 +262,9 @@ Redis.prototype.connect = function (callback) {
|
|
|
262
262
|
reject(new Error("Redis is already connecting/connected"));
|
|
263
263
|
return;
|
|
264
264
|
}
|
|
265
|
+
// Make sure only one timer is active at a time
|
|
265
266
|
clearInterval(this._addedScriptHashesCleanInterval);
|
|
267
|
+
// Start the script cache cleaning
|
|
266
268
|
this._addedScriptHashesCleanInterval = setInterval(() => {
|
|
267
269
|
this._addedScriptHashes = {};
|
|
268
270
|
}, this.options.maxScriptsCachingTime);
|