{"id":44791,"library":"drizzle-redis-cache","title":"drizzle-redis-cache","description":"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.","status":"active","version":"0.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/mohxmd/drizzle-redis-cache","tags":["javascript","drizzle","drizzle-orm","cache","redis","ioredis","bun","typescript"],"install":[{"cmd":"npm install drizzle-redis-cache","lang":"bash","label":"npm"},{"cmd":"yarn add drizzle-redis-cache","lang":"bash","label":"yarn"},{"cmd":"pnpm add drizzle-redis-cache","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; cache adapters integrate with Drizzle ORM query engine.","package":"drizzle-orm","optional":false},{"reason":"Required for IoRedisCache adapter; not needed for Bun native.","package":"ioredis","optional":true}],"imports":[{"note":"Named export from subpath '/ioredis'; default export not available.","wrong":"import { IoRedisCache } from 'drizzle-redis-cache'","symbol":"IoRedisCache","correct":"import { IoRedisCache } from 'drizzle-redis-cache/ioredis'"},{"note":"ESM-only package; CommonJS require will fail. Use dynamic import if needed.","wrong":"const { BunRedisCache } = require('drizzle-redis-cache');","symbol":"BunRedisCache","correct":"import { BunRedisCache } from 'drizzle-redis-cache/bun'"},{"note":"CommonJS require not supported; use dynamic import in CJS projects.","wrong":"const { IoRedisCache } = require('drizzle-redis-cache');","symbol":"IoRedisCache","correct":"const { IoRedisCache } = await import('drizzle-redis-cache/ioredis');"}],"quickstart":{"code":"import { drizzle } from 'drizzle-orm/node-postgres';\nimport { IoRedisCache } from 'drizzle-redis-cache/ioredis';\nimport { Pool } from 'pg';\n\nconst pool = new Pool({ connectionString: process.env.DATABASE_URL ?? '' });\nconst cache = new IoRedisCache({\n  url: process.env.REDIS_URL ?? 'redis://localhost:6379',\n  defaultTtl: 300,\n});\nconst db = drizzle({ client: pool, schema: {}, cache });\n\nasync function getUser(id: number) {\n  const result = await db.select().from(users).where(eq(users.id, id));\n  return result;\n}\n\n// Graceful shutdown\nprocess.on('SIGTERM', () => {\n  cache.disconnect();\n  pool.end();\n});","lang":"typescript","description":"Sets up a Drizzle ORM instance with IoRedisCache using ioredis and PostgreSQL, performs a cached query, and handles graceful shutdown."},"warnings":[{"fix":"Use import() or switch to ESM module resolution (type: module in package.json).","message":"Package is ESM-only. CommonJS require() will throw ERR_REQUIRE_ESM.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Use IoRedisCache for Node.js with ioredis; use BunRedisCache for Bun without ioredis.","message":"BunRedisCache requires Bun's native Redis client, not ioredis. Using ioredis in Bun causes compatibility issues.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Consider using 'explicit' strategy and opt-in with $withCache() for fine-grained control.","message":"The 'all' caching strategy caches every query automatically, which may lead to unintended memory pressure or stale data if not configured with appropriate TTL.","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"Always import from the specific subpath matching your runtime.","message":"Imports must use subpath exports: 'drizzle-redis-cache/ioredis' or 'drizzle-redis-cache/bun'. Direct import from root is undefined.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Upgrade Node.js to 20+ or use Bun 1.0+.","message":"Requires Node.js >=20 or Bun >=1.0. Older runtimes will fail on import.","severity":"breaking","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.1.0':15 '0.45':66 '5.0':69 'adapt':10 'altern':50 'automat':43 'awar':19 'bun':26,85 'cach':4,9,20,44,82 'client':29 'configur':31 'connect':18 'connection-awar':17 'design':46 'drizzl':2,12,64,78,80 'drizzle-orm':63,79 'drizzle-redis-cach':1 'explicit':41 'focus':74 'host':7 'invalid':36 'ioredi':22,68,84 'javascript':77 'level':35 'lightweight':49 'month':72 'nativ':27 'node.js':24,70 'orm':13,65,81 'provid':16 'redi':3,8,28,38,58,83 'releas':71 'requir':62 'run':55 'self':6 'self-host':5 'set':39 'ship':59 'stabil':76 'strategi':45 'support':30 'tabl':34 'table-level':33 'team':54 'ttl':32 'type':61 'typescript':60,86 'upstash':52 'version':14 'via':37","created_at":"2026-06-07T12:51:51.326143+00:00","updated_at":"2026-06-07T12:51:51.326143+00:00","problems":[{"fix":"Refactor to use dynamic import: const { IoRedisCache } = await import('drizzle-redis-cache/ioredis');","cause":"Package is ESM-only and cannot be loaded with require in CommonJS.","error":"ERR_REQUIRE_ESM: require() of ES Module /node_modules/drizzle-redis-cache/ioredis/index.js from /project/app.js not supported."},{"fix":"Ensure you use IoRedisCache with ioredis on Node.js, or BunRedisCache with Bun's built-in redis.","cause":"Using BunRedisCache with ioredis client; BunRedisCache expects Bun native Redis, not ioredis instance.","error":"TypeError: cache.disconnect() is not a function"},{"fix":"Update to latest version and ensure bundler supports package.json exports field (e.g., Webpack >=5, Vite, Rollup).","cause":"Package does not have default export; subpath export 'ioredis' missing in older version or bundler not configured.","error":"Module not found: Can't resolve 'drizzle-redis-cache/ioredis'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/mohxmd/drizzle-redis-cache#readme","github":"https://github.com/mohxmd/drizzle-redis-cache","docs":null,"changelog":null,"pypi":null,"npm":"drizzle-redis-cache","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}