Pattern 70 / CACHE

Singleflight

Use this when Collapsing identical work inside one process.

Pressure
Collapsing identical work inside one process
Mechanism
Use an in-process keyed promise/future so only one execution computes a value
Toll
Only helps per process unless paired with distributed coordination
Architecture plate70
Diagram for Singleflight
Executive brief

Singleflight fits when Collapsing identical work inside one process. Mechanism: Use an in-process keyed promise/future so only one execution computes a value. Use it for Hot cache misses and expensive local computations. The toll: Only helps per process unless paired with distributed coordination.

Use when

Hot cache misses and expensive local computations.

Example

Use singleflight when hot cache misses and expensive local computations..

Review framing

Describe the pressure first, then the mechanism, then the cost. That keeps the design grounded.

Same pressure family

Caching / Latency

69Request Coalescing
โ† 6971 โ†’