MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / writeCache

Function writeCache

apps/cloud/src/engine/execution-gate.ts:134–143  ·  view source on GitHub ↗
(organizationId: string, allowed: boolean, nowMs: number)

Source from the content-addressed store, hash-verified

132 const cache = new Map<string, { readonly allowed: boolean; readonly expiresAtMs: number }>();
133
134 const writeCache = (organizationId: string, allowed: boolean, nowMs: number): void => {
135 if (cache.size >= BALANCE_CACHE_MAX_ENTRIES) {
136 for (const [key, entry] of cache) {
137 if (entry.expiresAtMs <= nowMs) cache.delete(key);
138 }
139 // Still saturated after dropping expired entries: reset rather than grow.
140 if (cache.size >= BALANCE_CACHE_MAX_ENTRIES) cache.clear();
141 }
142 cache.set(organizationId, { allowed, expiresAtMs: nowMs + BALANCE_CACHE_TTL_MS });
143 };
144
145 const toDecision = (organizationId: string, allowed: boolean): GateDecision =>
146 allowed

Callers 1

decideFunction · 0.70

Calls 3

clearMethod · 0.80
deleteMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected