Skip to content

API reference > @kontsedal/olas-core > createCache

createCache() function โ€‹

A controller-local cache โ€” one fetcher, no sharing, no cache key (ยง5.1).

ts
const report = createCache(ctx, ({ signal, deps }) => deps.api.report({ signal }))

Unlike createQuery this needs **no** query engine: a local cache is not a cache-client entry. It still honours the root'squeryEngine({ defaults }), which the root reads without the client so that reading them cannot pull the engine into the bundle. Its fetches count toward root.waitForIdle() all the same.

Signature:

typescript
export declare function createCache<T>(ctx: Ctx, fetcher: (ctx: FetchCtx) => Promise<T>, options?: LocalCacheOptions<T>): LocalCache<T>;

Parameters โ€‹

Parameter

Type

Description

ctx

Ctx

fetcher

(ctx: FetchCtx) => Promise<T>

options

LocalCacheOptions<T>

(Optional)

Returns:

LocalCache<T>

Released under the MIT License.