cli/workspaces/cache at master ยท NodeSecure/cli

version OpenSSF Scorecard mit build

Disk-based caching layer for NodeSecure analysis payloads, with manifest tracking, MRU ordering, and integrity verification.

๐Ÿšง Requirements

๐Ÿ’ƒ Getting Started

This package is available in the Node Package Repository and can be easily installed with npm or yarn.

$ npm i @nodesecure/cache
# or
$ yarn add @nodesecure/cache

๐Ÿ’ก Features

  • ๐Ÿ’พ Persists analysis payloads to disk with integrity tracking and a manifest of available specs.
  • ๐Ÿ” Looks up cached payloads by package spec (name@version) or integrity hash.
  • ๐Ÿ• Iterates payloads in Most Recently Used (MRU) order, tracking the currently active payload.

๐Ÿ‘€ Usage example

import { PayloadCache } from "@nodesecure/cache";

const cache = new PayloadCache();
await cache.load();

// Save a payload (returned from @nodesecure/scanner)
await cache.save(
  payload,
  { useAsCurrent: true, scanType: "from" }
);

const found = await cache.findBySpec("express@4.18.2");

// Iterate all cached payloads in MRU order
for (const metadata of cache) {
  console.log(metadata.spec, metadata.lastUsedAt);
}

await cache.remove("express@4.18.2");

// Clear the entire cache
await cache.clear();

๐Ÿ“š API