Comparing version 4.27.2 to 4.27.3
@@ -64,4 +64,5 @@ "use strict"; | ||
} | ||
function shouldUseAutoPipelining(client, commandName) { | ||
return (client.options.enableAutoPipelining && | ||
function shouldUseAutoPipelining(client, functionName, commandName) { | ||
return (functionName && | ||
client.options.enableAutoPipelining && | ||
!client.isPipeline && | ||
@@ -72,3 +73,3 @@ !exports.notAllowedAutoPipelineCommands.includes(commandName) && | ||
exports.shouldUseAutoPipelining = shouldUseAutoPipelining; | ||
function executeWithAutoPipelining(client, commandName, args, callback) { | ||
function executeWithAutoPipelining(client, functionName, commandName, args, callback) { | ||
const CustomPromise = PromiseContainer.get(); | ||
@@ -83,3 +84,3 @@ // On cluster mode let's wait for slots to be available | ||
} | ||
executeWithAutoPipelining(client, commandName, args, callback).then(resolve, reject); | ||
executeWithAutoPipelining(client, functionName, commandName, args, callback).then(resolve, reject); | ||
}); | ||
@@ -118,3 +119,3 @@ }); | ||
}); | ||
pipeline[commandName](...args); | ||
pipeline[functionName](...args); | ||
}); | ||
@@ -121,0 +122,0 @@ return standard_as_callback_1.default(autoPipelinePromise, callback); |
@@ -26,2 +26,3 @@ "use strict"; | ||
this.scriptsSet = {}; | ||
this.addedBuiltinSet = new Set(); | ||
} | ||
@@ -51,12 +52,24 @@ exports.default = Commander; | ||
return { | ||
string: generateFunction(commandName, "utf8"), | ||
buffer: generateFunction(commandName, null), | ||
string: generateFunction(null, commandName, "utf8"), | ||
buffer: generateFunction(null, commandName, null), | ||
}; | ||
}; | ||
/** | ||
* Create add builtin command | ||
* | ||
* @param {string} commandName - command name | ||
* @return {object} functions | ||
* @public | ||
*/ | ||
Commander.prototype.addBuiltinCommand = function (commandName) { | ||
this.addedBuiltinSet.add(commandName); | ||
this[commandName] = generateFunction(commandName, commandName, "utf8"); | ||
this[commandName + "Buffer"] = generateFunction(commandName + "Buffer", commandName, null); | ||
}; | ||
commands.forEach(function (commandName) { | ||
Commander.prototype[commandName] = generateFunction(commandName, "utf8"); | ||
Commander.prototype[commandName + "Buffer"] = generateFunction(commandName, null); | ||
Commander.prototype[commandName] = generateFunction(commandName, commandName, "utf8"); | ||
Commander.prototype[commandName + "Buffer"] = generateFunction(commandName + "Buffer", commandName, null); | ||
}); | ||
Commander.prototype.call = generateFunction("utf8"); | ||
Commander.prototype.callBuffer = generateFunction(null); | ||
Commander.prototype.call = generateFunction("call", "utf8"); | ||
Commander.prototype.callBuffer = generateFunction("callBuffer", null); | ||
// eslint-disable-next-line @typescript-eslint/camelcase | ||
@@ -77,4 +90,4 @@ Commander.prototype.send_command = Commander.prototype.call; | ||
this.scriptsSet[name] = script; | ||
this[name] = generateScriptingFunction(name, script, "utf8"); | ||
this[name + "Buffer"] = generateScriptingFunction(name, script, null); | ||
this[name] = generateScriptingFunction(name, name, script, "utf8"); | ||
this[name + "Buffer"] = generateScriptingFunction(name + "Buffer", name, script, null); | ||
}; | ||
@@ -88,3 +101,3 @@ /** | ||
Commander.prototype.sendCommand = function () { }; | ||
function generateFunction(_commandName, _encoding) { | ||
function generateFunction(functionName, _commandName, _encoding) { | ||
if (typeof _encoding === "undefined") { | ||
@@ -114,10 +127,10 @@ _encoding = _commandName; | ||
// No auto pipeline, use regular command sending | ||
if (!autoPipelining_1.shouldUseAutoPipelining(this, commandName)) { | ||
if (!autoPipelining_1.shouldUseAutoPipelining(this, functionName, commandName)) { | ||
return this.sendCommand(new command_1.default(commandName, args, options, callback)); | ||
} | ||
// Create a new pipeline and make sure it's scheduled | ||
return autoPipelining_1.executeWithAutoPipelining(this, commandName, args, callback); | ||
return autoPipelining_1.executeWithAutoPipelining(this, functionName, commandName, args, callback); | ||
}; | ||
} | ||
function generateScriptingFunction(name, script, encoding) { | ||
function generateScriptingFunction(functionName, commandName, script, encoding) { | ||
return function () { | ||
@@ -151,8 +164,8 @@ let length = arguments.length; | ||
// No auto pipeline, use regular command sending | ||
if (!autoPipelining_1.shouldUseAutoPipelining(this, name)) { | ||
if (!autoPipelining_1.shouldUseAutoPipelining(this, functionName, commandName)) { | ||
return script.execute(this, args, options, callback); | ||
} | ||
// Create a new pipeline and make sure it's scheduled | ||
return autoPipelining_1.executeWithAutoPipelining(this, name, args, callback); | ||
return autoPipelining_1.executeWithAutoPipelining(this, functionName, commandName, args, callback); | ||
}; | ||
} |
@@ -44,2 +44,6 @@ "use strict"; | ||
}); | ||
redis.addedBuiltinSet.forEach((name) => { | ||
this[name] = redis[name]; | ||
this[name + "Buffer"] = redis[name + "Buffer"]; | ||
}); | ||
const Promise = PromiseContainer.get(); | ||
@@ -46,0 +50,0 @@ this.promise = new Promise((resolve, reject) => { |
@@ -0,1 +1,8 @@ | ||
## [4.27.3](https://github.com/luin/ioredis/compare/v4.27.2...v4.27.3) (2021-05-22) | ||
### Bug Fixes | ||
* autopipeling for buffer function ([#1231](https://github.com/luin/ioredis/issues/1231)) ([abd9a82](https://github.com/luin/ioredis/commit/abd9a82433ad67b91a4bddb45aff8da2e20d45e8)) | ||
## [4.27.2](https://github.com/luin/ioredis/compare/v4.27.1...v4.27.2) (2021-05-04) | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "ioredis", | ||
"version": "4.27.2", | ||
"version": "4.27.3", | ||
"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
289576
4808