compose

tagtree · /core·function

Chains multiple CacheAdapter implementations into one, reading from adapters in priority order until a hit is found and fanning writes and invalidations out to all of them. Adapter errors are caught, logged, and swallowed rather than propagated so a failing secondary never blocks a read.

Signature

@nordcom/commerce-tagtree
function compose(adapters: CacheAdapter[]): CacheAdapter;

Parameters

NameTypeDescription
adaptersCacheAdapter[]

Returns

A composite CacheAdapter that delegates every operation to all supplied backends.

Example

const adapter = compose(
    memoryAdapter({ maxEntries: 200 }),
    redisAdapter({ url: process.env.REDIS_URL }),
);
const cache = createCacheInstance(mySchema, adapter);

ContractTestOptions runAdapterContract AdapterCtx CacheAdapter CacheInstance CacheKey CacheSchema CacheSchemaShape

Sourcecompose.ts:19Edit the JSDoc directly

On this page