From 1fc5e5d0d3d71cdad94abd9c0f2bedb71cf8fabc Mon Sep 17 00:00:00 2001 From: yariplus Date: Sun, 16 Oct 2016 14:48:29 -0400 Subject: [PATCH] getSortedSetRevRangeByLex --- src/database/redis/sorted.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/database/redis/sorted.js b/src/database/redis/sorted.js index e02366c08f..e1fcb0cc8e 100644 --- a/src/database/redis/sorted.js +++ b/src/database/redis/sorted.js @@ -299,9 +299,25 @@ module.exports = function (redisClient, module) { if (max !== '+') { max = '(' + max; } - redisClient.zrangebylex([key, min, max, 'LIMIT', start, count], callback); + + sortedSetRangeByLex('zrangebylex', key, min, max, start, count, callback) }; + module.getSortedSetRevRangeByLex = function (key, max, min, start, count, callback) { + if (min !== '-') { + min = '[' + min; + } + if (max !== '+') { + max = '(' + max; + } + + sortedSetRangeByLex('zrevrangebylex', key, max, min, start, count, callback) + }; + + function sortedSetRangeByLex(method, key, min, max, start, count, callback) { + redisClient[method]([key, min, max, 'LIMIT', start, count], callback); + } + module.sortedSetIntersectCard = function (keys, callback) { if (!Array.isArray(keys) || !keys.length) { return callback(null, 0);