T
TanStack•9mo ago
modern-teal

Busting Persisted Cache

Hey all! I'm wondering what the recommended way of implementing cache busting with a sync storage persister is? I can see in the docs that I'm supposed to specify a buster value, but I'm not necessarily sure what that should be for my use case This is for a React Native app that should provide hybrid functionality (i.e., works with or without network connectivity), so I'd like to cache data as it comes in. As new data comes in, however, I would like to bust the previously stored data in order to keep the cache size down. Is there a way to bust cached data as new data comes in via Tanstack Query? I see there is a meta field that I can supply for queries, but I'm unsure of how to accomplish busting old data programmatically
2 Replies
xenophobic-harlequin
xenophobic-harlequin•9mo ago
data for the same key will be overwritten for different keys, you can set a lower gcTime to gargabe collect it from memory, and then it will automatically also be removed from the persisted storage
modern-teal
modern-tealOP•9mo ago
Sounds good! Thank you! 💜

Did you find this page helpful?