Skip to content

buildCache

buildCache(options): Cache

Defined in: packages/pipeline-cache/src/helpers/cache-factory.ts:158

Resolve the BuildCacheOptions into a ready-to-use cache-manager Cache. A pre-built cache wins, followed by pre-built stores, followed by declarative store configuration, falling back to an in-memory store when nothing is provided.

Package-created stores use throwOnErrors: true so cache failures reach CacheBehavior and its configured failure policy. Caller-owned cache and stores are not mutated: if an application intentionally shares a Keyv instance with another subsystem, this package must not change that object’s error semantics globally.

BuildCacheOptions

Cache

Fully package-owned Redis cache

const cache = buildCache({ store: { type: 'redis', url: redisUrl } });

Caller-owned shared store — configuration remains caller-controlled

const shared = new Keyv({ store: sharedRedis, throwOnErrors: false });
const cache = buildCache({ stores: [shared] });
// buildCache() will not mutate shared.throwOnErrors.