Skip to content

computeBuildCacheKey

computeBuildCacheKey(parentLayerId, command): Promise<string>

Defined in: packages/core/src/kernel/layer.ts:162

Compute the build cache key for a .run() step.

string | undefined

Id of the layer the step will run on top of, or undefined for base.

string

The shell command of the .run() step.

Promise<string>

A hex SHA-256 string suitable for BuildCache.get.

Key is sha256(parentLayerId + '|' + command). An undefined parent is hashed as the empty string, so base-layer steps still produce a stable key. Used by the builder to decide whether an upcoming .run() can be skipped by replaying the previously cached result layer.

import { computeBuildCacheKey, createBuildCache } from '@fishnet/core'
const cache = createBuildCache()
const key = await computeBuildCacheKey('abc123', 'apk add curl')
const cachedLayerId = cache.get(key)