Registry / database / bentocache

bentocache

JSON →
library1.6.1jsnpmunverified

Bentocache is a robust, multi-tier caching solution for Node.js, currently at version 1.6.1. It offers a rich set of features including multi-tier caching (local+distributed), bus-based L1 synchronization, cache stampede protection, graceful degradation with stale data, SWR-like strategies, namespaces, and tagging. Compared to simpler libraries like keyv, cache-manager, or unstorage, Bentocache is a full-featured caching solution designed for production-grade applications. It supports multiple drivers (Redis, Upstash, Cloudflare KV, File, In-memory, DynamoDB, Postgres, Sqlite) and ships with TypeScript types. The project follows a regular release cadence with active development.

npm install bentocache
INSTALL
IMPORT
SIG · BENTOCACHE
B
bentocache
databasejavascriptv1.6.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.

Bentocache
import { Bentocache } from 'bentocache'
const Bentocache = require('bentocache')
ESM-only since v1. No CJS support.
BentoCacheOptions
import { BentoCacheOptions } from 'bentocache'
import { Options } from 'bentocache'
Type import for configuring the cache instance.
RedisDriver
import { RedisDriver } from 'bentocache/drivers/redis'
import { Redis } from 'ioredis'
Drivers are imported from subpaths. RedisDriver is a wrapper around ioredis.
MemoryDriver
import { MemoryDriver } from 'bentocache/drivers/memory'
import { MemoryDriver } from 'bentocache'
Memory driver is used for L1 cache in multi-tier setup.

Shows single-level Redis and multi-tier (Memory+Redis) cache instantiation, set/get operations.

import { Bentocache } from 'bentocache'; import { MemoryDriver } from 'bentocache/drivers/memory'; import { RedisDriver } from 'bentocache/drivers/redis'; const cache = new Bentocache({ default: 'redis', stores: { memory: { driver: new MemoryDriver({ maxSize: 100 }), }, redis: { driver: new RedisDriver({ connection: { host: 'localhost', port: 6379 }, }), }, }, }); await cache.set('my-key', { user: 'john' }, { ttl: '1h' }); const value = await cache.get('my-key'); console.log(value); // { user: 'john' } // Multi-tier: L1=Memory, L2=Redis, Bus=Redis const multiCache = new Bentocache({ default: 'multi', stores: { multi: { driver: 'multi', layers: [ { driver: new MemoryDriver({ maxSize: 100 }) }, { driver: new RedisDriver({ connection: { host: 'localhost', port: 6379 } }) }, ], bus: { driver: 'redis', connection: { host: 'localhost', port: 6379 } }, }, }, }); await multiCache.set('multi-key', 42); const result = await multiCache.get('multi-key'); console.log(result); // 42
Debug
Known issues
gotchaRequires ESM imports - no CJS support. Using require() will fail.
fix
Use import syntax. If using CommonJS, consider dynamic import (import('bentocache')).
affects: >=1.0
breakingDriver subpath imports changed in v1.5.0 - drivers are now at bentocache/drivers/* instead of bentocache/dist/drivers/*.
fix
Update imports to use bentocache/drivers/redis etc.
affects: >=1.5.0
gotchaL2 driver must be installed separately. ioredis is not bundled.
fix
Install ioredis: npm install ioredis
affects: >=1.0
deprecated`ttl` option in set() now accepts human-readable strings (e.g., '1h'), but numeric values (seconds) still work. Official docs prefer strings.
fix
Use string format for clarity: ttl: '1h' instead of ttl: 3600.
affects: >=1.6.0
Errors
Common errors & fixes
Error: Cannot find module 'bentocache/dist/drivers/redis'
Old import path used in versions <1.5.0 or incorrect path.
fix
Update import to 'bentocache/drivers/redis' (without /dist/).
TypeError: Bentocache is not a constructor
Using require() on ESM-only package.
fix
Use import { Bentocache } from 'bentocache' instead of require.
Error: connect ECONNREFUSED 127.0.0.1:6379
Redis server not running or connection config incorrect.
fix
Ensure Redis is running on localhost:6379 or configure the connection properly.
Error: Cache store 'redis' not found. Available stores: memory
Store name mismatch or store not registered.
fix
Check that the driver is imported and registered under the correct name in stores config.
Upgrade
Version history
1.6.1latest on npm
Audit
Dependencies
@aws-sdk/client-dynamodboptionalRequired for DynamoDB driver
ioredisoptionalRequired for Redis driver
knexoptionalRequired for SQLite/Postgres driver (via knex)
kyselyoptionalRequired for SQL driver (via kysely)
orchid-ormoptionalRequired for SQL driver (via orchid-orm)
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
bentocache — npm install bentocache · libregistry