Unique key for the operation (e.g., 'GET /api/items?page=1')
Function that returns a Promise
Optional
optionsOrTtl: number | DedupeOptionsEither a number (ttlMs) or an options object
The resolved value from the operation, or cached value if available.
// Deduplicate concurrent fetches
async function loadPatients() {
return dedupe('GET:/api/patients', async () => {
const resp = await fetch('/api/patients');
return resp.json();
}, 5000); // 5s cache after resolution
}
// Two simultaneous calls will share the same network request
const [a, b] = await Promise.all([loadPatients(), loadPatients()]);
Deduplicate identical async calls and (optionally) cache results for a short TTL.
Backward-compatible signatures: dedupe(key, op) // no caching, no telemetry dedupe(key, op, 5000) // ttlMs as number dedupe(key, op, { ttlMs: 5000, report: true }) // with options & telemetry