Can the standard QueryPersister be combined with the experimental_createQueryPersister #9757
-
Can these two persisters be combined? The standard one being used to restore the query cache on app load and the experimental_createQueryPersister to store and refetch through the life of the application should the cache items become stale? Hope that makes sense and thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
These two persisters work in a different way. While both might be used at the same time, they will not work on the same cache, rather create two separate caches in your persistence layer.
It seems that you might want to use restoreQueries from |
Beta Was this translation helpful? Give feedback.
-
@DamianOsipiuk Really appreciate your response Damian - thank you. I appreciate and note that the persisters work differently. I have a slightly strange use case (in a chrome extension context) whereby I have an Index DB persister using the experimental_createQueryPersister which is in general working really well and allows a lot of control but, when pages change it would help me to not have to fetch all recent queries which could be 10,000 or so individually. In this case, using the two persisters together seemed like it might offer the best of both worlds! I think you're right though - it looks like restoreQueries would achieve a similar things - the entries function would just return the entirety of the IDB table when the persister is attached to the query client. The other option is for me to move to use the standard persister and just rely on the cache for fetching. Out of interest - how large/scalable is the cache. Is 10,000 entries in the standard cache a problem? Thanks so much! |
Beta Was this translation helpful? Give feedback.
QueryCache
should be good as it's a Map under the hood.QueryPersister
might start being a bottleneck after some threshold (depending on single query size and number of queries). This is due to a fact that after any change wholecache
state needs to beserialized
and stored as a single entry. So the more cache grows, the moreblocking time
you will see.Same thing goes for initial loading as we need to read and deserialize whole cache at once.
experimental_createQueryPersister
was designed to overcome that limitation, make things more performant and scale with your app, no matter how many queries you will have.Persistence layer will be checked whenever query mounts for the first time an…