Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

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

  • 💾 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