invalidate cache

This commit is contained in:
x
2025-05-01 16:34:29 -04:00
parent 296493484f
commit 9f1ac77afa
16 changed files with 253 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
import { TKeyStoreFactory } from "@app/keystore/keystore";
import { Lock } from "@app/lib/red-lock";
import RE2 from "re2";
export const mockKeyStore = (): TKeyStoreFactory => {
const store: Record<string, string | number | Buffer> = {};
@@ -18,6 +19,17 @@ export const mockKeyStore = (): TKeyStoreFactory => {
delete store[key];
return 1;
},
deleteItems: async (pattern) => {
const regex = new RE2(pattern.replace(/\*/g, ".*"));
let deletedCount = 0;
for (const key of Object.keys(store)) {
if (regex.test(key)) {
delete store[key];
deletedCount += 1;
}
}
return deletedCount;
},
getItem: async (key) => {
const value = store[key];
if (typeof value === "string") {