Skip to content

expose custom cache #4687

@TkDodo

Description

@TkDodo

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions