Function cachedCall

  • cachedCall executes the given async function and caches its result for subsequent calls. You can provide options for TTL, tags, custom key, key generator, or a custom cache instance.

    Usage: const data = await cachedCall(fetchData, { ttl: 600, tags: ["users"] }, 123);

    Type Parameters

    • T
    • A extends any[]

    Parameters

    • fn: (...args: A) => Promise<T>

      The async function to call if not cached.

    • options: CacheFunctionOptions = {}

      Optional caching parameters.

    • ...fnArgs: A

      Arguments to pass into the async function.

    Returns Promise<T>