Cache the blobs generated by scripts

This commit is contained in:
theit8514
2021-12-12 19:39:53 -05:00
parent ed86577d6c
commit 8f77f720e6
9 changed files with 136 additions and 20 deletions
+18
View File
@@ -0,0 +1,18 @@
const blobCache: { [hash: string]: string } = {};
export class BlobCache {
static get(hash: string) {
return blobCache[hash];
}
static store(hash: string, value: string): void {
if (blobCache[hash]) return;
blobCache[hash] = value;
}
static removeByValue(value: string) {
const keys = Object.keys(blobCache).filter((key) => blobCache[key] === value);
keys.forEach((key) => delete blobCache[key]);
}
}