feat: add server-side TTL cache + in-flight dedup to request handler

10s default TTL deduplicates concurrent requests from multiple clients
polling the same integration. 83 users hitting the same widget every
30s now produce ~6 upstream calls/min instead of ~166.
This commit is contained in:
Thomas Camlong committed 2026-07-02 18:17:04 +02:00
1 parent 8571b4dcb7
commit 33080e3d4f
1 file changed
-1
@@ -5,7 +5,6 @@ interface Options<TData, TInput extends Record<string, unknown>> {
type CacheEntry<TData> = { data: TData; timestamp: Date; expiresAt: number };
// ponytail: module-level cache keyed by JSON(input). Ceiling: unbounded keys if inputs are high-cardinality; upgrade to LRU if needed.
const cache = new Map<string, CacheEntry<unknown>>();
const inflight = new Map<string, Promise<CacheEntry<unknown>>>();