Registry / database / drizzle-redis-cache

drizzle-redis-cache

JSON →
library0.1.0jsnpmunverified

Self-hosted Redis cache adapters for Drizzle ORM (version 0.1.0) providing connection-aware caching with ioredis for Node.js and Bun native Redis client. Supports configurable TTL, table-level invalidation via Redis Sets, and explicit or automatic caching strategies. Designed as a lightweight alternative to Upstash for teams running their own Redis. Ships TypeScript types, requires drizzle-orm >=0.45 and ioredis >=5.0 (Node.js). Released monthly with focus on stability.

npm install drizzle-redis-cache
INSTALL
IMPORT
SIG · DRIZZLE-REDIS-CACH
D
drizzle-redis-cache
databasejavascriptv0.1.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.

IoRedisCache
✓ import { IoRedisCache } from 'drizzle-redis-cache/ioredis'
✗ import { IoRedisCache } from 'drizzle-redis-cache'
Named export from subpath '/ioredis'; default export not available.
BunRedisCache
✓ import { BunRedisCache } from 'drizzle-redis-cache/bun'
✗ const { BunRedisCache } = require('drizzle-redis-cache');
ESM-only package; CommonJS require will fail. Use dynamic import if needed.
IoRedisCache
✓ const { IoRedisCache } = await import('drizzle-redis-cache/ioredis');
✗ const { IoRedisCache } = require('drizzle-redis-cache');
CommonJS require not supported; use dynamic import in CJS projects.

Sets up a Drizzle ORM instance with IoRedisCache using ioredis and PostgreSQL, performs a cached query, and handles graceful shutdown.

import { drizzle } from 'drizzle-orm/node-postgres'; import { IoRedisCache } from 'drizzle-redis-cache/ioredis'; import { Pool } from 'pg'; const pool = new Pool({ connectionString: process.env.DATABASE_URL ?? '' }); const cache = new IoRedisCache({ url: process.env.REDIS_URL ?? 'redis://localhost:6379', defaultTtl: 300, }); const db = drizzle({ client: pool, schema: {}, cache }); async function getUser(id: number) { const result = await db.select().from(users).where(eq(users.id, id)); return result; } // Graceful shutdown process.on('SIGTERM', () => { cache.disconnect(); pool.end(); });
Debug
Known issues
breakingPackage is ESM-only. CommonJS require() will throw ERR_REQUIRE_ESM.
fix
Use import() or switch to ESM module resolution (type: module in package.json).
affects: >=0.1.0
gotchaBunRedisCache requires Bun's native Redis client, not ioredis. Using ioredis in Bun causes compatibility issues.
fix
Use IoRedisCache for Node.js with ioredis; use BunRedisCache for Bun without ioredis.
affects: >=0.1.0
deprecatedThe 'all' caching strategy caches every query automatically, which may lead to unintended memory pressure or stale data if not configured with appropriate TTL.
fix
Consider using 'explicit' strategy and opt-in with $withCache() for fine-grained control.
affects: >=0.1.0
gotchaImports must use subpath exports: 'drizzle-redis-cache/ioredis' or 'drizzle-redis-cache/bun'. Direct import from root is undefined.
fix
Always import from the specific subpath matching your runtime.
affects: >=0.1.0
breakingRequires Node.js >=20 or Bun >=1.0. Older runtimes will fail on import.
fix
Upgrade Node.js to 20+ or use Bun 1.0+.
affects: >=0.1.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module /node_modules/drizzle-redis-cache/ioredis/index.js from /project/app.js not supported.
Package is ESM-only and cannot be loaded with require in CommonJS.
fix
Refactor to use dynamic import: const { IoRedisCache } = await import('drizzle-redis-cache/ioredis');
TypeError: cache.disconnect() is not a function
Using BunRedisCache with ioredis client; BunRedisCache expects Bun native Redis, not ioredis instance.
fix
Ensure you use IoRedisCache with ioredis on Node.js, or BunRedisCache with Bun's built-in redis.
Module not found: Can't resolve 'drizzle-redis-cache/ioredis'
Package does not have default export; subpath export 'ioredis' missing in older version or bundler not configured.
fix
Update to latest version and ensure bundler supports package.json exports field (e.g., Webpack >=5, Vite, Rollup).
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
drizzle-ormrequiredPeer dependency; cache adapters integrate with Drizzle ORM query engine.
ioredisoptionalRequired for IoRedisCache adapter; not needed for Bun native.
Agent activity
11 hits · last 30 days
node
10
Resources
drizzle-redis-cache — npm install drizzle-redis-cache · libregistry