DrizzleORM with Upstash Redis
Quickstart
DrizzleORM provides an upstashCache()
helper to easily connect with Upstash Redis. To prevent surprises, the cache is always opt-in by default. Nothing is cached until you opt-in for a specific query or enable global caching.
- Install the package:
- Configure your Drizzle instance:
You can also explicitly define your Upstash credentials, enable global caching for all queries by default (opt-out) or pass custom caching options:
Cache Behavior
-
Per-query caching (opt-in, default):
No queries are cached unless you explicitly call.$withCache()
. -
Global caching:
When settingglobal: true
, all queries will read from cache by default.You can always turn off caching for a specific query:
Manual Cache Invalidation
Cache invalidation is fully automatic by default. If you ever need to, you can manually invalidate cached queries by table name or custom tags:
For more details on this integration, refer to the Drizzle ORM caching documentation.