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.
Type Declaration
Section titled “Type Declaration”false
{ staleWhileRevalidate?: string; tags?: string[]; ttl?: string; }
staleWhileRevalidate?
Section titled “staleWhileRevalidate?”
optionalstaleWhileRevalidate:string
Override the default stale-while-revalidate window for this query.
optionaltags:string[]
Tags for targeted manual invalidation via db.cache.invalidate({ tags }).
optionalttl:string
Override the default TTL for this query (e.g., "5m", "1h").
Example
Section titled “Example”// Skip cache entirelydb.query(posts).findMany({ cache: false });
// Custom TTL and tagsdb.query(posts).findMany({ cache: { ttl: "5m", tags: ["user-posts"] } });