or run

npx @tessl/cli init
Log in

Version

Files

docs

index-management.mdindex.mdlisting.mdreading.mdremoval.mdutilities.mdverification.mdwriting.md
tile.json

task.mdevals/scenario-7/

Digest-Based Cache Reader

A module that retrieves cached content directly by its integrity digest without needing cache keys.

Capabilities

Return cached bytes by digest

  • When the digest exists in the cache, return the full byte content and any stored metadata. @test
  • When the digest is absent, fail with a not-found style error. @test

Stream cached content by digest

  • Provide a readable stream for the digest that emits the stored content in order and ends cleanly. @test

Copy cached content by digest

  • Copy the cached content for the digest to a destination path and preserve the expected byte size. @test

Implementation

@generates

API

/**
 * Reads cached content by its integrity digest and returns the bytes plus any stored metadata.
 *
 * @param {string} cacheDir path to the cache directory
 * @param {string} digest integrity digest (e.g., sha512-...)
 * @param {{ expectedSize?: number, memoize?: boolean }} [options]
 * @returns {Promise<{ data: Buffer, metadata?: any, size: number, integrity: string }>}
 */
export async function fetchByDigest(cacheDir, digest, options);

/**
 * Returns a readable stream of cached content identified only by the digest.
 *
 * @param {string} cacheDir path to the cache directory
 * @param {string} digest integrity digest (e.g., sha512-...)
 * @param {{ memoize?: boolean }} [options]
 * @returns {NodeJS.ReadableStream}
 */
export function streamByDigest(cacheDir, digest, options);

/**
 * Copies cached content addressed by digest to a destination file path.
 *
 * @param {string} cacheDir path to the cache directory
 * @param {string} digest integrity digest (e.g., sha512-...)
 * @param {string} destination absolute or relative destination file path
 * @param {{ mode?: number, memoize?: boolean }} [options]
 * @returns {Promise<{ size: number, integrity: string }>}
 */
export async function copyByDigest(cacheDir, digest, destination, options);

Dependencies { .dependencies }

cacache { .dependency }

Digest-addressable cache storage and retrieval utilities.