A lightweight on-disk caching library for Node.js (v1.7.6) supporting locally mounted filesystems and remote filesystems like AWS S3. It provides time-based expiration policies with configurable default and per-item TTL. The library is ESM-only, ships TypeScript type definitions, and is actively maintained with a simple API. Alternatives like node-cache-manager or lru-cache offer in-memory or more complex caching, while this package focuses on simplicity and filesystem persistence.
npm install simple-on-disk-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates creating a cache on a locally mounted filesystem, setting and getting a value, and using custom expiration.
Create the directory before calling createCache, e.g., with fs.mkdirSync.
Only store JSON-serializable values.
Check for undefined: const result = get('key'); if (result === undefined) { /* not found or expired */ }Ensure AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and optionally AWS_REGION are available.
Use import { createCache } from 'simple-on-disk-cache' instead of require.Create the directory before creating the cache, e.g., with fs.mkdirSync('/path/to/dir', { recursive: true }).Ensure the value is JSON-serializable. Avoid storing functions or objects with circular references.
Set environment variables AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, or configure AWS CLI with aws configure.
No dependency data recorded yet.