Skip to content

Commit 97b3b20

Browse files
committed
randomly purge 10% of links cache
helps with retesting past keys in case they go stale
1 parent 93db70e commit 97b3b20

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

bin/validate-links.mts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ for await (const cacheFile of cacheWalker) {
3434

3535
console.log(`Found ${cachedKeys.size} cached links!`);
3636

37+
// randomly purge 10% of cache so we continuously check part of past links
38+
// this might help us catch any changed links
39+
let purgedKeys = 0;
40+
for (const cachedKey of cachedKeys) {
41+
if (Math.random() < 0.1) {
42+
cachedKeys.delete(cachedKey);
43+
purgedKeys++;
44+
}
45+
}
46+
47+
console.log(`Randomly purged ${purgedKeys} links from cache!`);
48+
3749
const wikiLinks = new Set<string>();
3850
const imageLinks = new Set<string>();
3951

0 commit comments

Comments
 (0)