You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using experimental_createPersister for IndexedDB cache.
Until a few minutes ago I was convinced that I could use method queryClient.getQueryData to get an element from the persisted cache even without the "momentary" cache being full.
I express myself with the terms "persisted" and "momentary" but I don't know if they are right.
Is getQueryData getting only from the "momentary" cache?
essentially, yes. getQueryData and setQueryData are synchronous functions that read from the in-memory cache. Thus, they cannot read from a persistent cache, because that would per definition be asynchronous.
This is essentially the same reason why setQueryData doesn't persist data, so it's related to:
If you want immediate cache restoration, please use the PersistQueryClientProvider. the createPersister api is meant for lazily filling the queryCache at the first time when the queryFn runs. You can run it with queryClient.ensureQueryData(). This will read from the in-memory cache, and run the queryFn (thus reading from the persistent cache) if there is no data loaded yet.
I'm using
experimental_createPersister
for IndexedDB cache.Until a few minutes ago I was convinced that I could use method queryClient.getQueryData to get an element from the persisted cache even without the "momentary" cache being full.
I express myself with the terms "persisted" and "momentary" but I don't know if they are right.
I created a small but effective reproduction of the problem here.
Steps to reproduce:
Open the first page of the app:
Click on "John" and on "Bob" links
The "persisted" cache and the "momentary" cache are filled now
Go to the Home page again
RELOAD THE PAGE
Click on the button "Try to get Player 2 from the cache"
See the message in console:
undefined
, DAMN!Why?
If you open the browser Dev Tools you can see in the IndexedDB the cache is there, filled up!
Why is Bob undefined?
Is
getQueryData
getting only from the "momentary" cache?The text was updated successfully, but these errors were encountered: