perf: closes #9994, bulk methods for settings

isekai-main
Baris Usakli 3 years ago
parent 72e1c281d7
commit d412ba4411

@ -69,16 +69,21 @@ Settings.set = async function (hash, values, quiet) {
await db.deleteAll(deleteKeys);
}));
const ops = [];
const sortedSetData = [];
const objectData = { keys: [], data: [] };
sortedLists.forEach((list) => {
const arr = sortedListData[list];
arr.forEach((data, order) => {
ops.push(db.sortedSetAdd(`settings:${hash}:sorted-list:${list}`, order, order));
ops.push(db.setObject(`settings:${hash}:sorted-list:${list}:${order}`, data));
sortedSetData.push([`settings:${hash}:sorted-list:${list}`, order, order]);
objectData.keys.push(`settings:${hash}:sorted-list:${list}:${order}`);
objectData.data.push(data);
});
});
await Promise.all(ops);
await Promise.all([
db.sortedSetAddBulk(sortedSetData),
db.setObjectBulk(objectData.keys, objectData.data),
]);
}
if (Object.keys(values).length) {

Loading…
Cancel
Save