withCache
Ce contenu n’est pas encore disponible dans votre langue.
withCache<
TData>(fn,__namedParameters):Promise<TData>
Defined in: utils/cache/withCache.ts:61
Returns the result of a given promise, and caches the result for subsequent invocations against a provided cache key.
Also deduplicates concurrent calls — if multiple callers request the same cache key while the promise is pending, they share the same promise.
Type Parameters
Section titled “Type Parameters”TData
Parameters
Section titled “Parameters”() => Promise<TData>
__namedParameters
Section titled “__namedParameters”WithCacheOptions
Returns
Section titled “Returns”Promise<TData>
Example
Section titled “Example”// First call fetches, subsequent calls return cached data for 30sconst data = await withCache( () => client.request({ method: "frak_getMerchantInformation" }), { cacheKey: "merchantInfo", cacheTime: 30_000 });