pre-bemis

This commit is contained in:
Marcelo
2026-04-22 05:04:19 +00:00
parent ac1a7900c8
commit 80d27f83b6
91 changed files with 11769 additions and 820 deletions

View File

@@ -2,7 +2,7 @@ import { prisma } from "@/lib/prisma";
type MachineAuth = { id: string; orgId: string };
const TTL_MS = 60_000;
const TTL_MS = 10_000;
const MAX_SIZE = 1000;
const cache = new Map<string, { value: MachineAuth; expiresAt: number }>();
@@ -36,3 +36,12 @@ export async function getMachineAuth(machineId: string, apiKey: string) {
cache.set(key, { value: machine, expiresAt: now + TTL_MS });
return machine;
}
export function invalidateMachineAuth(machineId: string) {
const prefix = `${machineId}:`;
for (const key of cache.keys()) {
if (key.startsWith(prefix)) {
cache.delete(key);
}
}
}