Cascadiq

Request Deduplication

project · Level 2 · 25 min

Description

Implement a deduplication layer: given a key (e.g. request id), only allow one in-flight request per key; others wait or get the same promise.

Requirements

  • dedupe(key, fn) -> same promise for same key while in flight
  • When fn resolves, clear the key so the next call runs again

Constraints

In-memory. Async/await.

Deliverables

Code for dedupe and a test scenario.

Tags

BackendAsync