Feature: Lazy page-by-page restoration for infinite queries with experimental_createQueryPersister #10078
Replies: 1 comment
-
|
TL;DR: The issue: when the persister restores, it loads it all into memory and shows a list of ~175 items, rather than the 25 of the first page.
My use case is a With the way that Goal: We should only see the first page, and every subsequent page will only be loaded into the query cache when it is paginated - fetching from the persister store if possible, otherwise over the network. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
The
experimental_createQueryPersisterstores and restores the entireInfiniteDataobject ({ pages: [...], pageParams: [...] }) as a single cache entry. When an infinite query is first used:persisterFnchecksquery.state.data === undefinedInfiniteDataat onceThe "lazy" restoration currently only means "restore when query is first used" - not "restore page by page". This causes performance issues when many pages are cached, as all pages are loaded into memory and rendered at once.
Use Case
When using infinite queries with persistence:
fetchNextPageis calledProposed Solution
Add support for page-by-page lazy restoration in the persister. The persister should:
fetchNextPage: Check if the requested page exists in persisted data before fetching from networkdataUpdatedAtto determine if cached pages are staleArchitecture
flowchart TD
subgraph storage [Persistent Storage]
FullData["Full InfiniteData\n{pages: [p1,p2,...], pageParams: [...]}"]
end
Beta Was this translation helpful? Give feedback.
All reactions