// Short-TTL cache for token -> environment lookups, so a page full of static assets doesn't // hit the Provisioner once per asset. Deliberately short (a few seconds) — correctness // (routing to a destroyed/reset environment) matters more than shaving a few Provisioner // round-trips, and a short TTL means a destroy/reset is reflected almost immediately. const TTL_MS = 5000; const cache = new Map(); // token -> { env, expiresAt } function get(token) { const hit = cache.get(token); if (!hit || hit.expiresAt < Date.now()) return null; return hit.env; } function set(token, env) { cache.set(token, { env, expiresAt: Date.now() + TTL_MS }); } function invalidate(token) { cache.delete(token); } module.exports = { get, set, invalidate };