Registry / database / cachedown

cachedown

JSON →
library1.0.0jsnpmunverified

A leveldown implementation that wraps an underlying leveldown store with an LRU cache for improved get/put performance. Version 1.0.0 is the latest stable release. It proxies all leveldown methods while caching recently accessed key-value pairs. Key differentiators: simple drop-in replacement for leveldown in levelup; supports configurable cache size and manual cache clearing. Requires leveldown as a peer dependency.

npm install cachedown
INSTALL
IMPORT
SIG · CACHEDOWN
C
cachedown
databasejavascriptv1.0.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.

default
import cachedown from 'cachedown'
const cachedown = require('cachedown')
ESM default import; CJS require works but ESM is recommended now.
cachedown.setLeveldown
import cachedown from 'cachedown'; cachedown.setLeveldown(leveldown)
const { setLeveldown } = require('cachedown')
Named export is not available; use default import then method.
cachedown instance
import cachedown from 'cachedown'; const db = new cachedown(location, underlyingLeveldown)
const db = new cachedown(location)
Second argument (underlying leveldown) is required unless setLeveldown was called first.

Shows setting default leveldown, creating levelup with cachedown, and basic put/get operations.

import levelup from 'levelup'; import leveldown from 'leveldown'; import cachedown from 'cachedown'; cachedown.setLeveldown(leveldown); const db = levelup('./mydb', { db: cachedown }); await db.put('key', 'value'); const val = await db.get('key'); console.log(val); // 'value'
Debug
Known issues
gotchaDefault cache max size is Infinity. If not manually limited, cache will grow unbounded.
fix
Set max size via instance.maxSize(number) or constructor options.
affects: >=1.0.0
breakingIn v1.0.0, the constructor signature changed to require the underlying leveldown instance as second argument (unless setLeveldown was called).
fix
Pass leveldown as second argument: new cachedown(location, leveldown) or use setLeveldown() beforehand.
affects: =1.0.0
gotchaCache is not persisted; process restart loses cached data but underlying store remains.
fix
No fix needed; it's by design. Ensure critical data is always read from underlying store after restart.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: cachedown is not a constructor
Missing 'new' keyword or incorrect import/require
fix
Use 'new cachedown(location, leveldown)' or ensure default import is correct.
Error: leveldown not found
Missing leveldown peer dependency or not passed/injected
fix
Install leveldown: npm install leveldown; then pass as second argument or call setLeveldown.
RangeError: Maximum call stack size exceeded
Infinite recursion when overwriting methods incorrectly or circular dependency
fix
Ensure you are not using cachedown as the underlying leveldown instance; pass the original leveldown.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
leveldownrequiredPeer dependency; needed as the underlying storage engine
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
cachedown — npm install cachedown · libregistry