Comparing version 4.27.5 to 4.27.6
@@ -21,9 +21,2 @@ "use strict"; | ||
]; | ||
function findAutoPipeline(client, _commandName, ...args) { | ||
if (!client.isCluster) { | ||
return "main"; | ||
} | ||
// We have slot information, we can improve routing by grouping slots served by the same subset of nodes | ||
return client.slots[calculateSlot(args[0])].join(","); | ||
} | ||
function executeAutoPipeline(client, slotKey) { | ||
@@ -87,3 +80,4 @@ /* | ||
} | ||
const slotKey = findAutoPipeline(client, commandName, ...args); | ||
// If we have slot information, we can improve routing by grouping slots served by the same subset of nodes | ||
const slotKey = client.isCluster ? client.slots[calculateSlot(args[0])].join(",") : 'main'; | ||
if (!client._autoPipelines.has(slotKey)) { | ||
@@ -90,0 +84,0 @@ const pipeline = client.pipeline(); |
@@ -45,2 +45,4 @@ "use strict"; | ||
this._autoPipelines = new Map(); | ||
this._groupsIds = {}; | ||
this._groupsBySlot = Array(16384); | ||
this._runningAutoPipelines = new Set(); | ||
@@ -131,3 +133,5 @@ this._readyDelayedCallbacks = []; | ||
} | ||
// Make sure only one timer is active at a time | ||
clearInterval(this._addedScriptHashesCleanInterval); | ||
// Start the script cache cleaning | ||
this._addedScriptHashesCleanInterval = setInterval(() => { | ||
@@ -496,2 +500,3 @@ this._addedScriptHashes = {}; | ||
} | ||
_this._groupsBySlot[slot] = _this._groupsIds[_this.slots[slot].join(';')]; | ||
_this.connectionPool.findOrCreate(_this.natMapper(key)); | ||
@@ -699,2 +704,16 @@ tryConnection(); | ||
} | ||
// Assign to each node keys a numeric value to make autopipeline comparison faster. | ||
this._groupsIds = Object.create(null); | ||
let j = 0; | ||
for (let i = 0; i < 16384; i++) { | ||
const target = (this.slots[i] || []).join(';'); | ||
if (!target.length) { | ||
this._groupsBySlot[i] = undefined; | ||
continue; | ||
} | ||
if (!this._groupsIds[target]) { | ||
this._groupsIds[target] = ++j; | ||
} | ||
this._groupsBySlot[i] = this._groupsIds[target]; | ||
} | ||
this.connectionPool.reset(nodes); | ||
@@ -701,0 +720,0 @@ callback(); |
@@ -18,6 +18,5 @@ "use strict"; | ||
const slot = calculateSlot(keys[0]); | ||
const target = redis.slots[slot].join(","); | ||
const target = redis._groupsBySlot[slot]; | ||
for (let i = 1; i < keys.length; i++) { | ||
const currentTarget = redis.slots[calculateSlot(keys[i])].join(","); | ||
if (currentTarget !== target) { | ||
if (redis._groupsBySlot[calculateSlot(keys[i])] !== target) { | ||
return -1; | ||
@@ -145,2 +144,3 @@ } | ||
_this.redis.slots[errv[1]] = [key]; | ||
_this.redis._groupsBySlot[errv[1]] = _this.redis._groupsIds[_this.redis.slots[errv[1]].join(";")]; | ||
_this.redis.refreshSlotsCache(); | ||
@@ -147,0 +147,0 @@ _this.exec(); |
@@ -265,3 +265,5 @@ "use strict"; | ||
} | ||
// Make sure only one timer is active at a time | ||
clearInterval(this._addedScriptHashesCleanInterval); | ||
// Start the script cache cleaning | ||
this._addedScriptHashesCleanInterval = setInterval(() => { | ||
@@ -268,0 +270,0 @@ this._addedScriptHashes = {}; |
@@ -0,1 +1,8 @@ | ||
## [4.27.6](https://github.com/luin/ioredis/compare/v4.27.5...v4.27.6) (2021-06-13) | ||
### Bug Fixes | ||
* fixed autopipeline performances. ([#1226](https://github.com/luin/ioredis/issues/1226)) ([42f1ee1](https://github.com/luin/ioredis/commit/42f1ee107174366a79ff94bec8a7a1ac353e035c)) | ||
## [4.27.5](https://github.com/luin/ioredis/compare/v4.27.4...v4.27.5) (2021-06-05) | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "ioredis", | ||
"version": "4.27.5", | ||
"version": "4.27.6", | ||
"description": "A robust, performance-focused and full-featured Redis client for Node.js.", | ||
@@ -5,0 +5,0 @@ "main": "built/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
291964
4830