#chache
3 messages · Page 1 of 1 (latest)
Hi @limber warren. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Convex already caches at the query function level, not at the individual db.get call level.
db.getis just a low-level read you use inside a query or mutation. It doesn’t have its own separate cache; it’s fast and intended to be used freely (including N+1 style patterns). [One-to-many]- Query functions (
query({ ... })) are what Convex automatically caches and keeps reactive. If you call the same query with the same args, Convex returns a cached result and only recomputes when underlying documents change. [Queries caching; Realtime]
So:
- You should not “replace
db.getwith query” for caching. - Instead, structure your reads so that all app reads go through query functions, and inside those queries you can use
db.get,db.query, etc. as needed. [Zen of Convex; Reading data]