|
|
@ -282,24 +282,28 @@ module.exports = function (module) {
|
|
|
|
|
|
|
|
|
|
|
|
const returnData = [];
|
|
|
|
const returnData = [];
|
|
|
|
let done = false;
|
|
|
|
let done = false;
|
|
|
|
|
|
|
|
const seen = {};
|
|
|
|
do {
|
|
|
|
do {
|
|
|
|
/* eslint-disable no-await-in-loop */
|
|
|
|
/* eslint-disable no-await-in-loop */
|
|
|
|
const res = await module.client.async.zscan(params.key, cursor, 'MATCH', params.match, 'COUNT', 100);
|
|
|
|
const res = await module.client.async.zscan(params.key, cursor, 'MATCH', params.match, 'COUNT', 5000);
|
|
|
|
cursor = res[0];
|
|
|
|
cursor = res[0];
|
|
|
|
done = cursor === '0';
|
|
|
|
done = cursor === '0';
|
|
|
|
const data = res[1];
|
|
|
|
const data = res[1];
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < data.length; i += 2) {
|
|
|
|
for (let i = 0; i < data.length; i += 2) {
|
|
|
|
const value = data[i];
|
|
|
|
const value = data[i];
|
|
|
|
const score = parseFloat(data[i + 1]);
|
|
|
|
if (!seen[value]) {
|
|
|
|
if (params.withScores) {
|
|
|
|
seen[value] = 1;
|
|
|
|
returnData.push({ value: value, score: score });
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (params.withScores) {
|
|
|
|
returnData.push(value);
|
|
|
|
returnData.push({ value: value, score: parseFloat(data[i + 2]) });
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (params.limit && returnData.length >= params.limit) {
|
|
|
|
returnData.push(value);
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
if (params.limit && returnData.length >= params.limit) {
|
|
|
|
|
|
|
|
done = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (!done);
|
|
|
|
} while (!done);
|
|
|
|