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
function defineCache(input: { entities: E; namespace: NS; qualifier: QualifierConfig<Q>; tenant: TenantConfig<T> }): CacheSchema<NS, T, Q, E>;Parameters
| Name | Type | Description |
|---|---|---|
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 } } },
});Related
ContractTestOptions runAdapterContract AdapterCtx CacheAdapter CacheInstance CacheKey CacheSchema CacheSchemaShape
MetadataOpen in GitHub ↗
createCacheInstance
Wires a CacheSchema definition to a storage adapter and returns a typed CacheInstance ready for read, write, and invalidate operations.
encodeSegment
Encodes a single cachekey segment so it is safe to join with . as a separator; escapes . and : in addition to the characters encodeURIComponent already handles.