Disk-based caching layer for NodeSecure analysis payloads, with manifest tracking, MRU ordering, and integrity verification.
- Node.js v24 or higher
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- 💾 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.
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();