Function withCache

  • withCache returns a new cached version of the given async function. Subsequent calls with the same arguments will return cached data for the TTL duration.

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

    Type Parameters

    • T extends (...args: any[]) => Promise<any>

    Parameters

    Returns T