defineCache

tagtree · /core·functionthrows When

Validates and freezes a cache schema definition, rejecting namespace or entity names that contain . (which would produce ambiguous dotted tags), then returns a CacheSchema ready to pass to createCacheInstance.

Signature

@nordcom/commerce-tagtree
function defineCache(input: { entities: E; namespace: NS; qualifier: QualifierConfig<Q>; tenant: TenantConfig<T> }): CacheSchema<NS, T, Q, E>;

Parameters

NameTypeDescription
input{ entities: E; namespace: NS; qualifier: QualifierConfig<Q>; tenant: TenantConfig<T> }

Returns

A validated CacheSchema wrapping the resolved shape.

Throws

When
input.namespace contains ..
When
any entity name in input.entities contains ..

Example

const productSchema = defineCache({
    namespace: 'commerce',
    tenant: { type: {} as Shop, key: (s) => s.id },
    entities: { product: { params: { id: str } } },
});

ContractTestOptions runAdapterContract AdapterCtx CacheAdapter CacheInstance CacheKey CacheSchema CacheSchemaShape

Sourceschema.ts:123Edit the JSDoc directly

On this page