mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 10:06:13 +01:00
zremrangebylex, zlexcount
This commit is contained in:
@@ -293,29 +293,45 @@ module.exports = function (redisClient, module) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.getSortedSetRangeByLex = function (key, min, max, start, count, callback) {
|
module.getSortedSetRangeByLex = function (key, min, max, start, count, callback) {
|
||||||
if (min !== '-') {
|
sortedSetLex('zrangebylex', false, key, min, max, start, count, callback)
|
||||||
min = '[' + min;
|
|
||||||
}
|
|
||||||
if (max !== '+') {
|
|
||||||
max = '(' + max;
|
|
||||||
}
|
|
||||||
|
|
||||||
sortedSetRangeByLex('zrangebylex', key, min, max, start, count, callback)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.getSortedSetRevRangeByLex = function (key, max, min, start, count, callback) {
|
module.getSortedSetRevRangeByLex = function (key, max, min, start, count, callback) {
|
||||||
|
sortedSetLex('zrevrangebylex', true, key, max, min, start, count, callback)
|
||||||
|
};
|
||||||
|
|
||||||
|
module.sortedSetRemoveRangeByLex = function (key, min, max) {
|
||||||
|
sortedSetLex('zremrangebylex', false, key, min, max, callback)
|
||||||
|
};
|
||||||
|
|
||||||
|
module.sortedSetLexCount = function (key, min, max) {
|
||||||
|
sortedSetLex('zlexcount', false, key, min, max, callback)
|
||||||
|
};
|
||||||
|
|
||||||
|
function sortedSetLex(method, reverse, key, min, max, start, count, callback) {
|
||||||
|
if (!callback) callback === start;
|
||||||
|
|
||||||
|
if (reverse) {
|
||||||
|
if (min !== '+') {
|
||||||
|
min = '(' + min;
|
||||||
|
}
|
||||||
|
if (max !== '-') {
|
||||||
|
max = '[' + max;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (min !== '-') {
|
if (min !== '-') {
|
||||||
min = '[' + min;
|
min = '[' + min;
|
||||||
}
|
}
|
||||||
if (max !== '+') {
|
if (max !== '+') {
|
||||||
max = '(' + max;
|
max = '(' + max;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sortedSetRangeByLex('zrevrangebylex', key, max, min, start, count, callback)
|
if (count) {
|
||||||
};
|
|
||||||
|
|
||||||
function sortedSetRangeByLex(method, key, min, max, start, count, callback) {
|
|
||||||
redisClient[method]([key, min, max, 'LIMIT', start, count], callback);
|
redisClient[method]([key, min, max, 'LIMIT', start, count], callback);
|
||||||
|
} else {
|
||||||
|
redisClient[method]([key, min, max], callback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.sortedSetIntersectCard = function (keys, callback) {
|
module.sortedSetIntersectCard = function (keys, callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user