Clearing Cache
How do I clear the queryCache for a particular query using the trpc context? If that's not possible, how can I do that using queryClient?
I've tried the above but it clears the entire cache. I just want to clear the cache of particular key.
Thank you!
10 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Oh I forgot to mention that I would like to clear the cache for an infinite query such that when the user queries for it again, it starts from scratch e.g. just the first 5 results.
But when I used invalidate queries, it seems to refetch all the results that were initially loaded. i.e. if the user loaded 15 results, the refetch would refetch all 15 results which is not what I wanted.
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I did the following:
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I see! Let me give that a shot! Thank you🤗
Actually, do I have to be more granular? I do want to clear the cache for all liked_place infinite queries.
currently my keys look like this:
[["liked_place","infiniteList"],{"folderId":"7218f699-78a8-4524-b15e-9a6c13e80af5","limit":5,"userId":"13dbca38-063d-4df7-bd1f-72908d1332fe"}]
and the user has several folders. So I just want to clear the entire cache for [liked_place, infinitelist]
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
oh, I actually want to invalidate the entire liked_place cache, not just the first 5.
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Alright! Thanks so much for your patience and help!(: Really appreciate it!