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

Function writeCache

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

Source from the content-addressed store, hash-verified

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

Callers 1

decideFunction · 0.70

Calls 3

clearMethod · 0.80
setMethod · 0.80
deleteMethod · 0.65

Tested by

no test coverage detected