Skip to content

QueryCacheOptions

QueryCacheOptions = false | { staleWhileRevalidate?: string; tags?: string[]; ttl?: string; }

Defined in: packages/db/src/types.ts:105

Per-query cache control options.

Pass false to skip caching for a specific query, or an options object to override the default CacheConfig for that query.

false

{ staleWhileRevalidate?: string; tags?: string[]; ttl?: string; }

optional staleWhileRevalidate: string

Override the default stale-while-revalidate window for this query.

optional tags: string[]

Tags for targeted manual invalidation via db.cache.invalidate({ tags }).

optional ttl: string

Override the default TTL for this query (e.g., "5m", "1h").

// Skip cache entirely
db.query(posts).findMany({ cache: false });
// Custom TTL and tags
db.query(posts).findMany({ cache: { ttl: "5m", tags: ["user-posts"] } });