diff --git a/lib/client/redis-client.js b/lib/client/redis-client.js index a6952f0..4e72d54 100644 --- a/lib/client/redis-client.js +++ b/lib/client/redis-client.js @@ -230,7 +230,11 @@ const getKeysVarArgs = function (args) { var keys = []; var hasCallback = typeof(args[args.length - 1]) === 'function'; for (var i = 0; i < (hasCallback ? args.length - 1 : args.length); i++) { - keys.push(args[i]); + if (Array.isArray(args[i])) { + keys = keys.concat(args[i]); + } else { + keys.push(args[i]); + } } var callback = hasCallback ? args[args.length - 1] : undefined; return {keys: keys, callback: callback}; diff --git a/test/client/redis-mock.keys.test.js b/test/client/redis-mock.keys.test.js index 8f73156..3e6cc2a 100644 --- a/test/client/redis-mock.keys.test.js +++ b/test/client/redis-mock.keys.test.js @@ -82,7 +82,7 @@ describe("exists", function () { }); - it("should return an array for multiple existing keys, existing and not", function (done) { + it("should return the correct amount of existing keys if passed as multiple args", function (done) { r.set("test", "test", function (err, result) { r.set("test2", "test", function (err, result) { r.exists("test", "test2", "nonexistant", function (err, result) { @@ -92,6 +92,17 @@ describe("exists", function () { }); }); }); + + it("should return the correct amount of existing keys if passed as an array arg", function (done) { + r.set("test", "test", function (err, result) { + r.set("test2", "test", function (err, result) { + r.exists(["test", "test2", "nonexistant"], function (err, result) { + result.should.eql(2); + done(); + }); + }); + }); + }); }); describe("type", function() {