Hey I m a long time Firebase dev I ve
Hey, I'm a long time Firebase dev. I've been bouncing around other "Realtime" databases this year trying out Supabase and Pocketbase. Today I found Convex and it really intrigues me.
1) Does a query function that returns cached value count as a function call (for billing purposes)?
2) Is there any local caching? Currently I'm storing all state data in one parent ContextProvider. Descendant components access data using useContext() hooks. Is this the recommended strategy for Convex or does local caching mean each child component uses useQuery() directly?
10 Replies
Check out https://docs.convex.dev/understanding/convex-fundamentals/functions#caching - with some details about caching.
If you're coming from firebase - you might enjoy this article too to articulate Convex well from that angle https://docs.convex.dev/understanding/convex-vs-firebase
Convex vs. Firebase | Convex Developer Hub
Convex and Google's Cloud Firestore are both platforms for managing database
Functions | Convex Developer Hub
But how do you get data into and out of these tables? In Convex, you use
Regarding (1): Convex charges for each time the function runs, but we don't actually run the query function until there is a mutation that would change the query result.
Thank you for the references. I read both those articles before posting and I still don't know the answer to the question.
IE - only when data changes does it count toward usage.
So, for example if two users are subscribed to the same data source; and there's a mutation. Only one function call is charged, but both users get the updated data. Correct?
Or if 1000 users are subscribed, and the data mutates, only one function call?
--- or perhaps 2. One for the mutation and one for the initial query. All other users are served cached data. Am I understanding that correctly?
lemme wait for one of my teammates to give a better answer!
wyliga hi! for now, yes, both of those count as function calls. as we get more sophisticated, especially with higher volume accounts, we're likely to consider discounts for cache hits vs. normal hits and that kind of a thing. but to keep things simple for right now, on both starter and pro accounts, any query call counts toward your query call quota
also, as time goes on and we get more confidence on global query cache hit rates, we'll likely find ways to price query calls very, very aggressively where the mixed pricing is "below cost" for a true function call. but we haven't really gotten far enough along yet to model that and factor all that in
queries are so good for you and your app, and good for us, that we really want to incentivize their usage over, say, actions
Good to know, thank you very much
no problem, thanks for trying convex! with your experience using other stacks, we'd love your experience report after you've spent some time with it!
I'll try to get a prototype of the app up and running with Convex and I'll let you know my experience.