Skip to content

Add a reusable promise cache for asynchronous computations #2229

Description

@jeswr

Several proposed performance changes need the same asynchronous caching
pattern: return an existing promise for a key, or create and cache one on a
miss. Caching the promise deduplicates concurrent calls as well as later calls.

A shared utility would avoid repeating this logic and provide consistent
choices for:

  • Map or WeakMap storage, depending on key lifetime;
  • eviction after rejection, so transient failures can be retried;
  • per-instance method caching through a decorator; and
  • custom key derivation for methods with multiple arguments.

The utility itself does not alter an existing hot path. Its performance effect
should be measured in the changes that adopt it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions