Registry / storage / lru-cache-fs

lru-cache-fs

JSON →
library2.0.1jsnpmunverified

Extends lru-cache with file system persistence. Current stable version: 2.0.1. Low release cadence (last update 2019). Key differentiator: adds fsDump() and automatic sync to disk using env-paths for os-specific paths, while maintaining full lru-cache API. Alternative to manual JSON serialization.

npm install lru-cache-fs
INSTALL
IMPORT
SIG · LRU-CACHE-FS
L
lru-cache-fs
storagejavascriptv2.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
const Cache = require('lru-cache-fs')
import Cache from 'lru-cache-fs'
Package does not provide ESM exports; using import will cause runtime error.
Cache
import Cache = require('lru-cache-fs')
import Cache from 'lru-cache-fs'
With TypeScript, use import = require for CommonJS modules.
new Cache()
const cache = new Cache({max: 100, cacheName: 'mycache'})
new Cache({max:100})
Without cacheName, default filename 'lru-cache-fs' is used, may collide.

Creates a file-backed LRU cache, sets and gets a value, then persists cache to disk.

const Cache = require('lru-cache-fs') const cache = new Cache({ max: 100, cacheName: 'myapp-cache' }) cache.set('key1', 'value1') console.log(cache.get('key1')) // 'value1' cache.fsDump()
Debug
Known issues
breakingimport statement not supported; package is CommonJS only.
fix
Use require() instead of import.
affects: >=2.0.0
gotchacacheName option is required for predictable file naming; default is 'lru-cache-fs'.
fix
Always provide descriptive cacheName option.
affects: >=1.0.0
deprecatedPackage not actively maintained; last update 2019.
fix
Consider forking or using alternative with ongoing support.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: lru_cache_fs_1.default is not a constructor
Using ES module import on CommonJS package.
fix
Replace 'import Cache from "lru-cache-fs"' with 'const Cache = require("lru-cache-fs")'.
Error: ENOENT: no such file or directory, mkdir '/root/.config/lru-cache-fs'
env-paths cannot create cache directory due to permissions.
fix
Run with appropriate permissions or set NODE_ENV to override paths.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
lru-cacherequiredcore caching logic
env-pathsrequireddetermine os-specific cache directory
Agent activity
18 hits · last 30 days
node
18
Resources
lru-cache-fs — npm install lru-cache-fs · libregistry