Dust.SingleFlight (dustlayer v0.1.2)

Copy Markdown View Source

Coordinated distributed cache-fill (a.k.a. single-flight) over a Dust lease.

For a key K, one caller in the fleet runs the expensive fun while every other caller rides the published result. Read-through, cache, memoize: this is the "compute once, share many" primitive.

It is at-least-once / single-flight while Dust is reachable, NOT exactly-once. lease_ttl expiry mid-run, a crash before publish, or the on_unavailable: :run_local degrade can all cause a second run. fun MUST be idempotent, published values MUST be small pointers (the bytes belong in S3/your DB), and followers MUST apply results idempotently.

See Dust.single_flight/4.

Summary

Functions

Run fun under coordination. See Dust.single_flight/4 for the contract.

Functions

run(store, key, fun, opts \\ [])

Run fun under coordination. See Dust.single_flight/4 for the contract.