simpler union

v1.18.x
barisusakli 11 years ago
parent 7f534cc7b8
commit f80b3c3b66

@ -83,18 +83,14 @@ module.exports = function(redisClient, module) {
} }
module.getSortedSetUnion = function(sets, start, stop, callback) { module.getSortedSetUnion = function(sets, start, stop, callback) {
var args = Array.prototype.slice.call(arguments, 0); sortedSetUnion(sets, false, start, stop, callback);
args.unshift(null);
sortedSetUnion.apply(null, args);
}; };
module.getSortedSetRevUnion = function(sets, start, stop, callback) { module.getSortedSetRevUnion = function(sets, start, stop, callback) {
var args = Array.prototype.slice.call(arguments, 0); sortedSetUnion(sets, true, start, stop, callback);
args.unshift(true);
sortedSetUnion.apply(null, args);
}; };
function sortedSetUnion(rev, sets, start, stop, callback) { function sortedSetUnion(sets, reverse, start, stop, callback) {
// start and stop optional // start and stop optional
if (typeof start === 'function') { if (typeof start === 'function') {
callback = start; callback = start;
@ -112,7 +108,7 @@ module.exports = function(redisClient, module) {
sets.unshift('temp'); sets.unshift('temp');
multi.zunionstore.apply(multi, sets); multi.zunionstore.apply(multi, sets);
multi[rev ? 'zrevrange' : 'zrange']('temp', start, stop); multi[reverse ? 'zrevrange' : 'zrange']('temp', start, stop);
multi.del('temp'); multi.del('temp');
multi.exec(function(err, results) { multi.exec(function(err, results) {
if (!err && typeof callback === 'function') { if (!err && typeof callback === 'function') {

Loading…
Cancel
Save