Registry / storage / cache-manager-fs

cache-manager-fs

JSON →
library1.0.12jsnpmunverified

A filesystem store for node-cache-manager that persists cached data to disk. The current stable version is 1.0.12. It supports JSON-serializable values, configurable TTL, maximum disk size, optional ZIP compression, and automatic cache refill on application restart. Unlike memory-only stores, this provides persistence across restarts and reduced memory usage. Release cadence is low; the package appears stable with minor updates.

npm install cache-manager-fs
INSTALL
IMPORT
SIG · CACHE-MANAGER-FS
C
cache-manager-fs
storagejavascriptv1.0.12
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.

default
const fsStore = require('cache-manager-fs');
import fsStore from 'cache-manager-fs';
This package does not provide ESM exports; use CommonJS require.
default
const { caching } = require('cache-manager'); const fsStore = require('cache-manager-fs'); const cache = caching({ store: fsStore });
const cache = require('cache-manager-fs');
cache-manager-fs is a store factory, not a cache instance. It must be used with cache-manager's caching() function.
default
import { caching } from 'cache-manager'; const fsStore = require('cache-manager-fs'); const cache = await caching({ store: fsStore });
import fsStore from 'cache-manager-fs';
Even when using ESM for cache-manager, cache-manager-fs must be required or imported via default with a workaround.

Demonstrates basic setup with cache-manager and cache-manager-fs, including set, get, and ttl operations.

const cacheManager = require('cache-manager'); const fsStore = require('cache-manager-fs'); const diskCache = cacheManager.caching({ store: fsStore, options: { path: 'diskcache', ttl: 60 * 60, maxsize: 1000 * 1000 * 1000, zip: true, preventfill: true } }); (async () => { await diskCache.set('myKey', 'myValue'); const val = await diskCache.get('myKey'); console.log(val); // 'myValue' const ttl = await diskCache.ttl('myKey'); console.log(ttl); // 3600 })();
Debug
Known issues
gotchacache-manager-fs does not support ESM imports. Attempting to use import will fail.
fix
Use require() instead.
affects: >=1.0.0
gotchaThe package is a store factory and must be used with cache-manager, not standalone.
fix
Use cacheManager.caching({ store: fsStore, options: {...} })
affects: >=1.0.0
gotchaOptions must be passed inside an 'options' object to caching(), not directly to the store.
fix
Use caching({ store: fsStore, options: { path: ..., ttl: ... } })
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'cache-manager'
Missing peer dependency cache-manager.
fix
npm install cache-manager
TypeError: cacheManager.caching is not a function
Incorrect import of cache-manager or using wrong API.
fix
Ensure you require('cache-manager') correctly and use caching() method.
SyntaxError: Unexpected identifier in import statement
Using ESM import with a CommonJS-only package.
fix
Use require() instead of import.
Upgrade
Version history
1.0.12latest on npm
Audit
Dependencies
cache-managerrequiredRequired peer dependency; this is a store for cache-manager.
Agent activity
25 hits · last 30 days
node
24
Resources
cache-manager-fs — npm install cache-manager-fs · libregistry