Registry / storage / extra-disk-cache

extra-disk-cache

JSON →
library0.13.0jsnpmunverified

A disk-based persistent cache library for Node.js (v0.13.0, requires Node >=22). It stores key-value pairs as files on disk, supports optional TTL, and provides synchronous API for most operations. Includes DiskCache, DiskCacheWithCache (in-memory + disk), DiskCacheView (typed keys/values via converters), and DiskCacheAsyncView (async converters). Differentiators: full TypeScript support, minimal dependencies, sync API for simplicity, and composable view layers. Alternative to quick-lru or lru-cache for persistent use cases.

npm install extra-disk-cache
INSTALL
IMPORT
SIG · EXTRA-DISK-CACHE
E
extra-disk-cache
storagejavascriptv0.13.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.

DiskCache
import { DiskCache } from 'extra-disk-cache'
import DiskCache from 'extra-disk-cache'
The package exports named exports only; no default export.
DiskCacheWithCache
import { DiskCacheWithCache } from 'extra-disk-cache'
const { DiskCacheWithCache } = require('extra-disk-cache')
Package is ESM-only; CJS require is not supported.
DiskCacheView
import { DiskCacheView } from 'extra-disk-cache'
import { DiskCacheView } from 'extra-disk-cache'
Use named import as with all exports.

Creates a DiskCache, sets a key with TTL 1 hour, retrieves it, and closes the cache.

import { DiskCache } from 'extra-disk-cache'; import ms from 'ms'; async function main() { const cache = await DiskCache.create('/tmp/cache'); cache.set('key', Buffer.from('value'), ms('1h')); const value = cache.get('key')?.toString(); console.log('Cached value:', value); cache.close(); } main().catch(console.error);
Debug
Known issues
breakingDiskCache.create() is async and must be awaited
fix
Use `await DiskCache.create(path)`
affects: >=0.0.0
gotchaset() requires Buffer values; strings or objects cause TypeScript errors
fix
Wrap values in Buffer.from() or use DiskCacheView with a converter
affects: >=0.0.0
deprecatedNode.js >=22 required; older Node.js versions are not supported
fix
Upgrade to Node.js >=22
affects: >=0.13.0
Errors
Common errors & fixes
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'extra-disk-cache' imported from ...
Package not installed or not in node_modules
fix
Run `npm install extra-disk-cache`
TypeError: DiskCache.create is not a function
Incorrect import: using default import instead of named import
fix
Use `import { DiskCache } from 'extra-disk-cache'`
Upgrade
Version history
0.13.0latest on npm
Audit
Dependencies
msoptionalUsed in examples for converting time strings to milliseconds, but not a hard dependency.
Agent activity
21 hits · last 30 days
node
18
Amazon
1
Resources
extra-disk-cache — npm install extra-disk-cache · libregistry