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
function createCacheInstance(cache: CacheSchema<NS, T, Q, E>, adapter: CacheAdapter, options: { logger: ILogger }): CacheInstance<NS, T, Q, E>;Parameters
| Name | Type | Description |
|---|---|---|
cache | CacheSchema<NS, T, Q, E> | |
adapter | CacheAdapter | |
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,
});Related
ContractTestOptions runAdapterContract AdapterCtx CacheAdapter CacheInstance CacheKey CacheSchema CacheSchemaShape
MetadataOpen in GitHub ↗
ContractTestOptions
Configuration passed to runAdapterContract; declares how to create and tear down the adapter under test and which optional protocol features the adapter support
defineCache
Validates and freezes a cache schema definition, rejecting namespace or entity names that contain . (which would produce ambiguous dotted tags), then returns a