firefly-limiter - v1.0.1
    Preparing search index...

    Class SingleFlight<K>

    Collapses concurrent calls that share a key into one call.

    It stores nothing once a call settles: the next caller starts a new one. That is the whole difference between this and a cache, and it is why there is no expiry to configure. A cache is storage with an invalidation story, which belongs in your data layer.

    The shared call is abandoned only when every caller has abandoned it: each caller's signal detaches that caller, and the last one to leave aborts the work.

    Type Parameters

    • K = string
    Index
    • Whether a call is in flight under key.

      Parameters

      • key: K

      Returns boolean

    • Runs action under key, or joins the call already running under it.

      Type Parameters

      • T

      Parameters

      • key: K
      • action: Action<T>
      • Optionalsignal: AbortSignal

      Returns Promise<T>