Registry / database / node-file-cache

node-file-cache

JSON →
library1.0.2jsnpmunverified

node-file-cache is a straightforward, file-based caching module for Node.js, currently at version 1.0.2. It leverages `lowdb` for persistent storage, allowing developers to store key-value pairs with optional lifespans and tags for granular expiry. Its design emphasizes simplicity over advanced features or high-throughput performance. Given its age and the explicit mention of Node.js 4.4.5 as a minimum requirement (a version from 2016), it appears to be an unmaintained package with an irregular or non-existent release cadence. It's best suited for small-scale applications where a simple, durable, local cache is sufficient and high concurrency or complex cache invalidation strategies are not required.

npm install node-file-cache
INSTALL
IMPORT
SIG · NODE-FILE-CACHE
N
node-file-cache
databasejavascriptv1.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

create
const cache = require('node-file-cache').create();
import { create } from 'node-file-cache'; // Not supported, CommonJS only
The module exports a `create` factory function directly from the `require` call. It does not support ES modules.
createWithOptions
const cache = require('node-file-cache').create({ file: 'my-cache.json', life: 7200 });
const { create } = require('node-file-cache')(); // Incorrect destructuring and invocation, `create` is a function itself
Configuration options are passed directly to the `create` factory function upon instantiation.
CacheInstance
const cache = require('node-file-cache').create(); cache.set('key', 'value');
const cache = require('node-file-cache'); cache.set('key', 'value'); // Missing the .create() invocation to get an instance
The `require` call itself does not return the cache instance; you must call the `create()` method on the result.

Demonstrates initializing the cache, setting a record with options (lifespan, tags), retrieving it, and then explicitly expiring it by key.

const cache = require('node-file-cache').create(); // default configuration const key = 'my-cache-key'; const item = { name: 'my cache item' }; const options = { life: 60, // set lifespan of one minute tags: [ 'my-cache-tag', 'another-tag' ] }; cache.set(key, item, options); const cachedItem = cache.get(key); // depending on context this can either return cached data or null if (cachedItem) { console.log(`Cached item: ${cachedItem.name}`); } // To demonstrate removal setTimeout(() => { cache.expire(key); // removes item with particular key console.log(`Cache size after expiry: ${cache.size()}`); }, 1000); // Wait a bit to ensure async operation completes and cache is still there before expiry
Debug
Known issues
breakingThe module explicitly requires Node.js version 4.4.5 or higher due to its use of ES6 features. Running it on significantly older Node.js versions will result in syntax errors.
fix
Upgrade Node.js to at least version 4.4.5. However, due to the package's age, it's recommended to use a modern caching solution for current Node.js applications.
affects: <4.4.5
gotchaThis package appears to be unmaintained. The README states 'Since the github repository is not ready yet', implying it was never actively hosted or updated for a long period. This means no bug fixes, security patches, or compatibility updates for newer Node.js versions.
fix
Evaluate modern, actively maintained caching libraries (e.g., `node-cache`, `cache-manager`, `ioredis` for Redis-based) for new projects or when migrating existing applications.
affects: >=1.0.0
gotchaBeing a file-based cache using `lowdb`, `node-file-cache` may not be suitable for high-concurrency environments or applications requiring high performance. Concurrent writes could lead to race conditions, data corruption, or significant I/O bottlenecks.
fix
For high-performance or concurrent caching needs, consider in-memory caches or external cache services like Redis or Memcached.
affects: >=1.0.0
gotchaThe package only supports CommonJS `require()` syntax. Attempting to import it using ES module `import` statements will result in runtime errors.
fix
Always use `const cache = require('node-file-cache').create();` to import and instantiate the cache module.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: (0, _nodeFileCache.create) is not a function
Attempting to use ES module `import` syntax (`import { create } from 'node-file-cache';`) with this CommonJS-only package.
fix
Change your import statement to `const cache = require('node-file-cache').create();`
ReferenceError: require is not defined
Attempting to use `require()` in an ES module context (`'type': 'module'` in package.json or `.mjs` file).
fix
This package is not compatible with pure ES module environments. You would either need to transpile your code, convert your project to CommonJS, or use a different caching library that supports ES modules.
Error: Cannot find module 'node-file-cache'
The package `node-file-cache` has not been installed or is not resolvable from the current working directory.
fix
Run `npm install node-file-cache --save` in your project directory.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
lowdbrequiredUsed as the underlying file storage wrapper for persistence.
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
node-file-cache — npm install node-file-cache · libregistry