Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/client/redis-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
13 changes: 12 additions & 1 deletion test/client/redis-mock.keys.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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() {
Expand Down