remove dupe code

v1.18.x
barisusakli 11 years ago
parent 7d3d9f5ae1
commit 9aacb5e259

@ -25,25 +25,19 @@ module.exports = function(redisClient, module) {
multi.sismember(key, values[i]); multi.sismember(key, values[i]);
} }
multi.exec(function(err, results) { execSetMembers(multi, callback);
if (err) {
return callback(err);
}
for (var i=0; i<results.length; ++i) {
results[i] = results[i] === 1;
}
callback(null, results);
});
}; };
module.isMemberOfSets = function(sets, value, callback) { module.isMemberOfSets = function(sets, value, callback) {
var multi = redisClient.multi(); var multi = redisClient.multi();
for (var i = 0; i < sets.length; ++i) { for (var i = 0; i < sets.length; ++i) {
multi.sismember(sets[i], value); multi.sismember(sets[i], value);
} }
execSetMembers(multi, callback);
};
function execSetMembers(multi, callback) {
multi.exec(function(err, results) { multi.exec(function(err, results) {
if (err) { if (err) {
return callback(err); return callback(err);
@ -54,7 +48,7 @@ module.exports = function(redisClient, module) {
} }
callback(null, results); callback(null, results);
}); });
}; }
module.getSetMembers = function(key, callback) { module.getSetMembers = function(key, callback) {
redisClient.smembers(key, callback); redisClient.smembers(key, callback);

Loading…
Cancel
Save