incepter / suspense-query

react hooks for suspense and transition based data fetching
MIT License
3 stars 0 forks source link

Cache management #7

Open incepter opened 1 year ago

incepter commented 1 year ago

enabling cache should act on the Fiber query property

if cache is enabled, the query is replaced by a wrapper around the original query, that performs caching around args.

This can be done either by using React.cache or a small abstraction leveraging memoizing function returns based on inputs args identity, or a custom hash function by provided by the user.

incepter commented 1 year ago

To support SSR, cache should be serializable, and thus provided by userland, such as a hash function as options;

signature:

Options<T, A extends unknown[], R>: {
  // ...
  cacheHash: (...args: A) => string;
  // ...
}