Skip to content

cache

cache(options): PipelineBehaviorTuple<CacheBehavior, CacheBehaviorOptions>

Defined in: packages/pipeline-cache/src/helpers/cache.intent.ts:35

Returns a cache behavior entry for pipeline.wrap() or createPipeline({ globalBehaviors }).

CacheIntentOptions

A key factory and cache options, or inheritModuleKey: true when the behavior’s constructor defaults supply the key factory. The inheritance marker is not forwarded to the behavior and does not validate module configuration.

PipelineBehaviorTuple<CacheBehavior, CacheBehaviorOptions>

The behavior class and options tuple. Keys for authorized responses must separate tenant, principal and permission scope; prefer createPartitionedCacheKeyFactory for those responses.

export const getUsers = pipeline.wrap(
{ name: 'getUsers', kind: 'query' },
cache({ key: userCacheKey, ttl: 30_000 }),
)(loadUsers);
// The key factory comes from the CacheBehavior constructor defaults.
const entry = cache({ inheritModuleKey: true, ttl: 30_000 });