-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix: create separate cache entries for non-exported queries #14499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 54444c3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
||
if (cache === undefined) { | ||
cache = {}; | ||
(state.remote_data ??= new Map()).set(info, cache); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use a WeakMap
here so that the info
object key can be garbage collected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole thing will be garbage collected after state
becomes obsolete, so I don't think we need it / should do it.
Co-authored-by: Tee Ming <chewteeming01@gmail.com>
Queries are cached on the server per-request — that is, calling
myQuery()
multiple times will only invoke the function once.At present, the cache key is a combination of the query
id
and the stringified argument (if there is one), but this doesn't work if the query doesn't have anid
, because it isn't exported from a.remote.ts
file. This PR fixes it.Non-exported queries are probably somewhat rare, but this is useful for things like an
isAuthenticated()
query that's used in multiple places.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.Edits