repletes - v1.1.0
    Preparing search index...

    Class Cache<T>

    A store plus every decision about caching one kind of thing. Construct it once and share it deliberately.

    The cache belongs outside your retry and rate-limit layers: a hit should not consume a bulkhead slot. Only a miss becomes a call.

    Type Parameters

    • T
    Index
    • Empty the store. Optional on the Store interface and potentially O(n). A store shared by several caches is cleared entirely, namespace or not.

      Returns Promise<void>

    • Drop one key. This is the mechanism; deciding when a write made a read wrong is the caller's, because a cache cannot see it.

      Parameters

      • key: string

      Returns Promise<void>

    • What the store holds, without calling anything and without triggering a refresh. undefined when nothing readable is there.

      Parameters

      • key: string

      Returns Promise<Result<T> | undefined>

    • wrap, with where the value came from. Use this when a caller has to tell a fresh answer from one that survived an upstream failure.

      Parameters

      Returns Promise<Result<T>>

    • Resolves once no background refresh is in flight. For tests and for shutdown; a caller never has to await a refresh to get an answer.

      Returns Promise<void>

    • The value behind a key, from the store when the windows say so and from action when they do not.

      An action failure on a miss rethrows untouched. An action failure covered by staleIfError serves the retained value instead.

      Parameters

      Returns Promise<T>