query icon indicating copy to clipboard operation
query copied to clipboard

expose custom cache

Open TkDodo opened this issue 3 years ago • 0 comments

context

Inspired by swr cache provider, we can allow to pass a "custom cache" into our QueryCache:

new QueryClient({
  queryCache: new QueryCache({
    cache: myCache
  })
})

The cache would have to adhere to a map-like interface, and we should probably re-write our internal object to a standard Map.

This would allow features like:

  • limit cache size (as discussed here)
    • you could evict unused cache entries by other criteria than being time-based
  • persist to local storage on a per-query basis
    • limitation: writes could be async, but reads would need to be sync
  • reset cache between test runs (we can already do that in different ways though)
  • other use-cases I haven't thought of?

proposal

  • re-write internal cache object to a Map
  • allow custom caches to be passed in that adhere to a map-like interface

TkDodo avatar Dec 23 '22 07:12 TkDodo