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:
@@ -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);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user