Skip to content

expose custom cache #4687

Closed
Closed

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

Activity

  1. added this to the v5 milestone on Dec 23, 2022
  2. self-assigned this
    on Dec 28, 2022
  3. linked a pull request that will close this issueFeature/custom cache #4726on Dec 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions