dont need to call multi if keys.length is 0

v1.18.x
Barış Soner Uşaklı 6 years ago
parent 20abc7fc47
commit 48690a01b9

@ -363,7 +363,7 @@ module.exports = function (db, module) {
module.getSortedSetsMembers = function (keys, callback) {
if (!Array.isArray(keys) || !keys.length) {
return callback(null, []);
return setImmediate(callback, null, []);
}
db.collection('objects').find({ _key: { $in: keys } }, { projection: { _id: 0, score: 0 } }).sort({ score: 1 }).toArray(function (err, data) {
if (err) {

@ -172,6 +172,9 @@ module.exports = function (redisClient, module) {
};
module.getSortedSetsMembers = function (keys, callback) {
if (!Array.isArray(keys) || !keys.length) {
return setImmediate(callback, null, []);
}
var multi = redisClient.multi();
for (var i = 0; i < keys.length; i += 1) {
multi.zrange(keys[i], 0, -1);

Loading…
Cancel
Save