Starlord
Starlord3mo ago

fine-grained caching

Hey, Lets say we have Twitter like system with messages and likes of messages. Do I understand it right that getMessages paginated query would completely wipe it's cache once any message like count changes and refresh all messages instead of only this one? I think this is very important problem that's there is no caching control for developers.
6 Replies
jamwt
jamwt3mo ago
this is true for now, but only until we enable subquery caching. Nothing architectural that's inherently limited. you can also manage it yourself for now by breaking queries up into a parent component that gets the message ids only and then individual components query the individual messages. this will eventually be possible purely server-side, but isn't just yet ( ^ a few high load sites have done this workaround for now to scale )
Starlord
StarlordOP3mo ago
ok i understand. but would be easier if it will be handled on the server side. thanks Is there a possible timeline when this subquery caching will be added? Paginated query is already causing for me a lot of database consumption and with adding dynamic parameters as likes it will be like there is no caching at all. Every like dislike of a user will reset the cache
jamwt
jamwt3mo ago
I'd guess it's at least 3-6 months out
Starlord
StarlordOP3mo ago
https://www.convex.dev/components/sharded-counter using this will not help here or? changes to shared counter will still resett the cache right?
Convex
Sharded Counter
Scalable counter that can increment and decrement with high throughput.
jamwt
jamwt3mo ago
that mostly helps with reducing write contention on incrementing use cases
Starlord
StarlordOP3mo ago
ok my solution was to use this for now for like count. and to have and extra query for every "message" to fetch like count. thats hacky and would be better to send it with messages but thats how it is for now

Did you find this page helpful?