createCacheInstance

tagtree · /core·function

Wires a CacheSchema definition to a storage adapter and returns a typed CacheInstance ready for read, write, and invalidate operations.

Signature

@nordcom/commerce-tagtree
function createCacheInstance(cache: CacheSchema<NS, T, Q, E>, adapter: CacheAdapter, options: { logger: ILogger }): CacheInstance<NS, T, Q, E>;

Parameters

NameTypeDescription
cacheCacheSchema<NS, T, Q, E>
adapterCacheAdapter
options{ logger: ILogger }

Returns

A fully-typed CacheInstance bound to the schema's entity and tenant shapes.

Example

const productCache = createCacheInstance(productSchema, memoryAdapter(), {
    logger: consoleLogger,
});

ContractTestOptions runAdapterContract AdapterCtx CacheAdapter CacheInstance CacheKey CacheSchema CacheSchemaShape

Sourcecache.ts:71Edit the JSDoc directly

On this page