perf: use setObjectBulk

v1.18.x
Barış Soner Uşaklı 4 years ago
parent a07509f770
commit 95033ef756

@ -15,12 +15,15 @@ module.exports = {
const keys = tids.map(tid => `tid:${tid}:posters`); const keys = tids.map(tid => `tid:${tid}:posters`);
await db.sortedSetsRemoveRangeByScore(keys, '-inf', 0); await db.sortedSetsRemoveRangeByScore(keys, '-inf', 0);
const counts = await db.sortedSetsCard(keys); const counts = await db.sortedSetsCard(keys);
const setKeys = [];
const data = [];
for (let i = 0; i < tids.length; i++) { for (let i = 0; i < tids.length; i++) {
if (counts[i] > 0) { if (counts[i] > 0) {
// eslint-disable-next-line no-await-in-loop setKeys.push(`topic:${tids[i]}`);
await db.setObjectField(`topic:${tids[i]}`, 'postercount', counts[i]); data.push({ postercount: counts[i] });
} }
} }
await db.setObjectBulk(setKeys, data);
}, { }, {
progress: progress, progress: progress,
batchSize: 500, batchSize: 500,

Loading…
Cancel
Save