Registry / storage / recacheman-file

recacheman-file

JSON →
library1.1.0jsnpmunverified

File-based caching library for Node.js (v1.1.0, stable, updated 2024). Fork of cacheman-file with support for Node.js 20+ and TypeScript types. Provides a simple key-value store on disk with TTL support. Used as a cache engine for the recacheman multi-engine cache library. Offers set, get, del, clear, getAll operations. Alternative to node-cache or memory-cache with persistent storage.

npm install recacheman-file
INSTALL
IMPORT
SIG · RECACHEMAN-FILE
R
recacheman-file
storagejavascriptv1.1.0
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.

CachemanFile
const CachemanFile = require('recacheman-file');
import CachemanFile from 'recacheman-file';
This package uses CommonJS. ESM import may not work without a default export wrapper.
CachemanFile
import CachemanFile = require('recacheman-file');
import * as CachemanFile from 'recacheman-file';
TypeScript users should use `import = require` syntax for CJS modules.
default
const cache = new (require('recacheman-file'))();
const cache = new cachemanFile();
The module exports the constructor directly, not as a named export.

Basic usage: create a file cache instance, set a value with TTL, retrieve it, then delete.

const CachemanFile = require('recacheman-file'); const cache = new CachemanFile(); cache.set('key', { data: 'value' }, 60, (err) => { if (err) throw err; cache.get('key', (err, value) => { if (err) throw err; console.log(value); // { data: 'value' } cache.del('key', (err) => { if (err) throw err; console.log('deleted'); }); }); });
Debug
Known issues
breakingVersion 1.x drops support for Node.js <20. If using Node.js 10-18, stick to v0.x.
fix
Upgrade to Node.js 20+ or use recacheman-file@0.x.
affects: >=1.0.0
gotchaCache files are stored in OS temp directory by default. Clearing temp may unexpectedly delete all cached data.
fix
Specify a custom directory via constructor options: new CachemanFile({dir: '/my/cache/path'})
affects: >=0.0.0
gotchaset() with TTL expects seconds. Passing milliseconds will cause unexpected early expiry.
fix
Ensure TTL is in seconds (e.g., 3600 for 1 hour).
affects: >=0.0.0
deprecatedget() and set() with callbacks are synchronous in nature but use callbacks. Future versions may support promises.
fix
Wrap calls in a Promise if needed: const get = (key) => new Promise((resolve, reject) => cache.get(key, (err, val) => err ? reject(err) : resolve(val)));
affects: >=1.0.0
Errors
Common errors & fixes
Error: ENOENT: no such file or directory, open '/tmp/recacheman/...'
Default cache directory does not exist or permission denied.
fix
Ensure /tmp is writable or specify a custom directory with write permissions.
TypeError: cache.set is not a function
Forgot to instantiate with 'new', or imported incorrectly.
fix
Use: const cache = new CachemanFile();
Error: Cannot find module 'recacheman-file'
Package not installed or import path wrong.
fix
Run 'npm install recacheman-file' and ensure require('recacheman-file') is correct.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
28 hits · last 30 days
node
26
OpenAI (training)
1
Resources
recacheman-file — npm install recacheman-file · libregistry