Registry / storage / cache-point

cache-point

JSON →
library3.0.1jsnpmunverified

Simple, filesystem-backed memoisation cache for Node.js. Current stable version is 3.0.1, released under the MIT license. The package provides a Cache class that stores serialised results on disk, keyed by checksums of input arguments. Cache hits resolve the stored value; misses reject with ENOENT. It supports synchronous and asynchronous read/write, custom cache directories, clearing, and removal. Unlike in-memory caches (e.g., lru-cache), cache-point persists across process restarts. Requires node >= 12.17 and has a peer dependency on @75lb/nature (ESM utilities). The project follows semantic versioning with a slow release cadence (last release Nov 2022).

npm install cache-point
INSTALL
IMPORT
SIG · CACHE-POINT
C
cache-point
storagejavascriptv3.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Cache
import Cache from 'cache-point'
const Cache = require('cache-point')
Package is ESM-only since v3; CommonJS require() will fail with ERR_REQUIRE_ESM
Cache
import { Cache } from 'cache-point'
const { Cache } = require('cache-point')
Named export also available but default export is recommended per documentation
Cache
const Cache = (await import('cache-point')).default
const { default: Cache } = require('cache-point')
Dynamic import is the workaround for CJS projects; the named export is identical to default

Demonstrates basic cache operations: write, read with hit/miss handling, and clear.

import Cache from 'cache-point'; const cache = new Cache({ dir: 'tmp/cache' }); async function example() { // Write to cache await cache.write('myKey', { data: 'hello' }); // Read from cache (on hit) const value = await cache.read('myKey'); console.log(value); // { data: 'hello' } // Read with miss handling try { const missing = await cache.read('nonexistent'); } catch (err) { if (err.code === 'ENOENT') { console.log('Cache miss'); } } // Clear all entries await cache.clear(); } example();
Debug
Known issues
breakingv3.0.0 dropped CommonJS support; package is ESM-only. Use dynamic import in CJS projects or upgrade to ESM.
fix
Use import (static or dynamic) instead of require(). Ensure package.json has type: module or use .mjs extension.
affects: >=3.0.0
breakingv3.0.0 requires Node.js >= 12.17. Older Node versions will throw SyntaxError for ESM syntax.
fix
Upgrade Node.js to >= 12.17.0.
affects: >=3.0.0
gotchaRead method rejects with ENOENT on miss, not undefined. Must use try/catch or .catch() to handle misses.
fix
Wrap cache.read() in try/catch and check err.code === 'ENOENT'. Or use cache.readSync() which returns undefined on miss.
affects: >=1.0.0
gotchaKeys can be any JSON-serializable value; non-serializable keys (e.g., functions) will cause errors.
fix
Ensure keys are strings, numbers, booleans, arrays, or plain objects. Avoid symbols, functions, or circular references.
affects: >=1.0.0
deprecatedNo deprecation warnings known. Package is actively maintained.
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module /path/to/node_modules/cache-point/index.js from /path/to/app.js not supported.
Using require() with an ESM-only package (v3+).
fix
Switch to import statement or use dynamic import: const Cache = (await import('cache-point')).default;
SyntaxError: Unexpected token 'export'
Running an ESM package in a Node.js version < 12.17 or without proper module configuration.
fix
Upgrade Node.js to >= 12.17 and ensure package.json includes "type": "module" or use .mjs extension.
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/path/to/node_modules/@75lb/nature'
Missing peer dependency @75lb/nature, which is required if not using optional features that bypass it.
fix
Run npm install @75lb/nature or install cache-point with --legacy-peer-deps if not needed.
TypeError: cache.read(...) is not a function
Using named import { Cache } incorrectly (e.g., importing a non-existent function) or using an older version without that method.
fix
Ensure you are importing Cache from 'cache-point' correctly: import Cache from 'cache-point'; then use new Cache().read().
Upgrade
Version history
3.0.1latest on npm
Audit
Dependencies
@75lb/natureoptionalProvides ESM utilities (e.g., mkdirp, rimraf) used internally
Agent activity
23 hits · last 30 days
node
22
Resources
cache-point — npm install cache-point · libregistry