Good way to cache database query results?

Like is using just setinterval to variable that queries database enough. And then return that variable on get request. Variable would run to query let's say once a minute.
2 Replies
steakfisher
steakfisher10mo ago
There's no universally good method.. it differs depending on how often ur data is read from, and written to
Mocha
Mocha10mo ago
React Query handles a lot of that logic for you, and you can adjust stale settings if you don’t want it to refetch. If it’s some other global cache, there could be some libraries or you could build a simple context or variable for it