Skip to content

Can you please explain this better to me? Is gcTime a way to avoid the getItem call? #6214

Answered by DamianOsipiuk
frederikhors asked this question in Q&A
Discussion options

You must be logged in to vote

This setup will work as follows:

  • after queryFn run it will be persisted in idb
  • if query becomes unused for less than 30s it will be still referenced from memory (idb will not be called)
  • after all observers unmount (query becomes unused), it will be garbage collected after 30s, but persisted state remains unchanged
  • after particular query becomes used again, it will be restored from idb, and then refetched in the background for updates.
  • If query is unused and last fetch happend more than 12h ago, persisted state will be discarded, and next usage will go trough hard loading state.

This way you can keep your memory usage lower, since unused queries can be garbage collected, while still bein…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by TkDodo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants