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:
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>>>();
|
||||
|
||||
|
||||
Reference in new issue
Block a user