$ show npm/cacache
cacache is a Node.js library implementing a content-addressable cache system. It provides key-based and content-addressable access to cached data with built-in integrity verification using Subresource Integrity (SRI) standards. The system is designed for high concurrency and fault tolerance, protecting against corruption, partial writes, and race conditions. It features a modular architecture separating concerns like index management, content storage, memoization, and verification/garbage collection.
The LLM identified 3 files worth highlighting for reuse:
Implements a sophisticated LRU cache with size-based limits (50MB) and time-based TTL (3 minutes). Supports both key-based and digest-based caching with flexible injection points for custom cache implementations. Demonstrates advanced caching strategies including size calculation based on entry type and proper cleanup mechanisms.
Provides a clean interface for temporary directory management with automatic cleanup. Uses @npmcli/fs.withTempDir underneath but adds proper error handling and ensures temporary directories are properly removed after use. Demonstrates proper resource management patterns for temporary file handling.
Implements robust content reading with integrity verification using Subresource Integrity standards. Handles large files via streaming to avoid memory issues, supports multiple hash algorithms in a single SRI reference, and provides comprehensive error handling for various failure modes including missing files, corruption, and size mismatches.