{"id":42651,"library":"drizzle-uncache","title":"drizzle-uncache","description":"A cache adapter for Drizzle ORM that uses unstorage as the backend, allowing you to plug in any unstorage driver (Redis, LRU, filesystem, Cloudflare KV, Upstash, etc.). Version 1.0.0 requires drizzle-orm >=0.45.1 and unstorage >=1.17.3. It implements Drizzle's custom cache interface and provides storage-agnostic caching with per-query TTL overrides, global caching, and debug logging. Unlike driver-specific cache solutions, this package is lightweight and unopinionated about the driver. Known not to support SQLite-based drivers (better-sqlite3, bun-sqlite, etc.) with drizzle-orm 0.45.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/dschewchenko/drizzle-uncache","tags":["javascript","typescript"],"install":[{"cmd":"npm install drizzle-uncache","lang":"bash","label":"npm"},{"cmd":"yarn add drizzle-uncache","lang":"bash","label":"yarn"},{"cmd":"pnpm add drizzle-uncache","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: provides the Drizzle ORM custom cache interface and query builder","package":"drizzle-orm","optional":false},{"reason":"Peer dependency: provides the storage abstraction and driver system","package":"unstorage","optional":false}],"imports":[{"note":"ESM-only; CommonJS require() will not work because the package is ESM. Named export, not default.","wrong":"const { unstorageCache } = require('drizzle-uncache')","symbol":"unstorageCache","correct":"import { unstorageCache } from 'drizzle-uncache'"},{"note":"Side-effect import is possible but not recommended; use named imports.","wrong":"","symbol":"drizzle-uncache","correct":"import 'drizzle-uncache'"},{"note":"unstorage exports named exports; default import is undefined.","wrong":"import unstorage from 'unstorage'","symbol":"unstorage","correct":"import { createStorage } from 'unstorage'"}],"quickstart":{"code":"import { unstorageCache } from 'drizzle-uncache';\nimport { createStorage } from 'unstorage';\nimport redisDriver from 'unstorage/drivers/redis';\nimport { drizzle } from 'drizzle-orm/node-postgres';\nimport { Client } from 'pg';\n\nconst storage = createStorage({ driver: redisDriver({ url: process.env.REDIS_URL ?? 'redis://localhost:6379' }) });\nconst cache = unstorageCache({ storage, config: { ex: 60 } });\n\nconst client = new Client({ connectionString: process.env.DATABASE_URL ?? 'postgres://localhost/mydb' });\nawait client.connect();\n\nconst db = drizzle(client, { cache });\n\nconst result = await db.select().from(users).$withCache({ config: { ex: 120 } });","lang":"typescript","description":"Initializes an unstorage Redis-backed cache, connects to PostgreSQL via Drizzle, and runs a cached query."},"warnings":[{"fix":"Use a different driver (Redis, LRU, fs-lite, etc.) or upgrade to a future version that may support SQLite drivers.","message":"Unsupported SQLite-based drivers with drizzle-orm v0.45","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Always set at least one TTL field if you want entries to expire. Use `keepTtl: true` to preserve the existing entry's TTL.","message":"`config` TTL fields (`ex`/`px`/`exat`/`pxat`) are converted to an absolute `expiresAt` timestamp stored with the cache entry. Some drivers ignore TTL options, but drizzle-uncache enforces expiry by checking this timestamp.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Choose a consistent `base` value and do not change it after the cache is populated, or implement a migration strategy.","message":"The `base` option defaults to `'drizzle:cache'`. All cache keys are prefixed with this string. If you change it after populating the cache, old entries will be ignored.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use `global: true` only after verifying that your application tolerates cached results. Use per-query `.withCache()` for selective caching.","message":"The `global` option caches all queries by default. If you enable it, every query will be cached unless you explicitly opt out with `.$noCache()`. This might lead to stale data if not configured carefully.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Only enable debug in development. Remove or set `debug: false` in production.","message":"Debug logging (`debug: true`) outputs HIT/MISS and PUT/INVALIDATE messages via `console.log`. This can flood the console in production.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'0.45':99 '0.45.1':37 '1.0.0':32 '1.17.3':40 'adapt':6 'agnost':52 'allow':16 'backend':15 'base':86 'better':89 'better-sqlite3':88 'bun':92 'bun-sqlit':91 'cach':5,46,53,61,69 'cloudflar':27 'custom':45 'debug':63 'driver':23,67,79,87 'driver-specif':66 'drizzl':2,8,35,43,97 'drizzle-orm':34,96 'drizzle-uncach':1 'etc':30,94 'filesystem':26 'global':60 'implement':42 'interfac':47 'javascript':100 'known':80 'kv':28 'lightweight':74 'log':64 'lru':25 'orm':9,36,98 'overrid':59 'packag':72 'per':56 'per-queri':55 'plug':19 'provid':49 'queri':57 'redi':24 'requir':33 'solut':70 'specif':68 'sqlite':85,93 'sqlite-bas':84 'sqlite3':90 'storag':51 'storage-agnost':50 'support':83 'ttl':58 'typescript':101 'uncach':3 'unlik':65 'unopinion':76 'unstorag':12,22,39 'upstash':29 'use':11 'version':31","created_at":"2026-06-05T16:56:00.518168+00:00","updated_at":"2026-06-05T16:56:00.518168+00:00","problems":[{"fix":"Ensure `unstorage` is installed and the specific driver package (e.g., `@unstorage/driver-redis`) is installed if required. For Redis, install `ioredis` and use the correct driver path.","cause":"Importing from `unstorage/drivers/redis` without the driver package installed or using an incompatible unstorage version.","error":"ERR_PACKAGE_PATH_NOT_EXPORTED: Package subpath './drivers/redis' is not defined by \"exports\" in .../unstorage/package.json"},{"fix":"Install drizzle-uncache: `npm install drizzle-uncache`. Ensure TypeScript >= 4.7 and set `moduleResolution: \"node16\"` or `\"bundler\"` in tsconfig.json.","cause":"The package is not installed or TypeScript cannot resolve the types. drizzle-uncache ships its own types, but the `exports` field may not be picked up by older TypeScript versions.","error":"Cannot find module 'drizzle-uncache' or its corresponding type declarations."},{"fix":"Run `npm install drizzle-orm@^0.45.1 unstorage@^1.17.3` along with drizzle-uncache.","cause":"drizzle-uncache requires drizzle-orm as a peer dependency, which is not automatically installed by npm.","error":"Error: The \"drizzle-orm\" peer dependency is not installed. You must install peer dependencies yourself."},{"fix":"Wrap the storage in an options object: `unstorageCache({ storage: myStorage, config: { ex: 60 } })`","cause":"Incorrect usage: `unstorageCache` expects an object with `storage` property, but the user passed an unstorage instance directly.","error":"Error: storeItem is not a function"}],"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/dschewchenko/drizzle-uncache#readme","github":"https://github.com/dschewchenko/drizzle-uncache","docs":null,"changelog":null,"pypi":null,"npm":"drizzle-uncache","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}