mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-05 05:52:46 +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(){
|
export async function versionHistoryGarbageCollection(){
|
||||||
const entries = await IDB.entries();
|
const entries = await IDB.entries();
|
||||||
|
|
||||||
|
const expiredKeys = [];
|
||||||
for (const [key, value] of entries){
|
for (const [key, value] of entries){
|
||||||
const expireAt = new Date(value.savedAt);
|
const expireAt = new Date(value.savedAt);
|
||||||
expireAt.setMinutes(expireAt.getMinutes() + GARBAGE_COLLECT_DELAY);
|
expireAt.setMinutes(expireAt.getMinutes() + GARBAGE_COLLECT_DELAY);
|
||||||
if(new Date() > expireAt){
|
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