0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-25 09:42:40 +00:00

Shift grabage collection to use delMany instead of a looped del

This commit is contained in:
G.Ambatte
2024-10-12 10:57:01 +13:00
parent cdbb2fa26a
commit f64e7d3fd7

View File

@@ -105,11 +105,15 @@ export async function updateHistory(brew) {
export async function versionHistoryGarbageCollection(){
const entries = await IDB.entries();
const expiredKeys = [];
for (const [key, value] of entries){
const expireAt = new Date(value.savedAt);
expireAt.setMinutes(expireAt.getMinutes() + GARBAGE_COLLECT_DELAY);
if(new Date() > expireAt){
await IDB.del(key);
expiredKeys.push(key);
};
};
if(expiredKeys.length > 0){
await IDB.delMany(expiredKeys);
}
};