Skip to the content.

cache

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

👀 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