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-2/

Metadata Cache Writer

Utility to persist content in a disk-backed cache by human-readable keys while attaching metadata to each entry.

Capabilities

Persist keyed content with metadata

  • Saving string content to a key returns the content integrity string and persists provided metadata fields retrievable on later lookups. @test
  • Writing a Buffer with an expected size succeeds only when the data length matches and the same metadata is stored alongside the entry. @test

Streamed writes with metadata

  • Writing data from a readable stream resolves when the stream finishes, yields the final integrity and size, and stores the supplied metadata. @test

JSON convenience writes

  • Accepting a plain object serializes it to JSON, stores it under the given key with merged metadata (including a default contentType flag), and returns the integrity string. @test

Implementation

@generates

API

export async function saveContent(cachePath, key, content, options);
/**
 * Stores string or Buffer content at the given key with metadata.
 * Resolves to the integrity string for the stored content.
 * options.metadata holds user-supplied metadata; options.expectedSize enforces byte length.
 * options.algorithms optionally overrides hashing algorithms.
 */

export async function saveStream(cachePath, key, readable, options);
/**
 * Streams data from a readable into cache under the key with metadata.
 * Resolves to an object containing integrity and size numbers after the stream finishes.
 * options.metadata holds user-supplied metadata; options.expectedSize enforces byte length when provided.
 * Emits size/integrity through resolved return, not events.
 */

export async function saveJson(cachePath, key, data, options);
/**
 * Serializes a plain object to JSON and stores it under the key with metadata.
 * Automatically sets metadata.contentType = 'application/json' when not already provided.
 * Resolves to the integrity string for the stored JSON payload.
 */

Dependencies { .dependencies }

cacache { .dependency }

Provides the disk-backed cache with keyed writes, streaming support, and metadata storage. @satisfied-by