@vsokolov/utils - v1.4.2
    Preparing search index...

    Function withCache

    • Wraps an async function with caching.

      Type Parameters

      • TArgs extends unknown[]
      • TResult

      Parameters

      • fn: (...args: TArgs) => Promise<TResult>

        The async function to cache

      • cacheInstance: LRUCacheAPI<{ cached: boolean; result: TResult }>

        The cache instance to use

      • getKey: (...args: TArgs) => string

        Function to generate cache key from arguments

      Returns (...args: TArgs) => Promise<{ cached: boolean; result: TResult }>