WIP: Allow createSelector
to store a cache
#21547
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@see #20330 which is basically the same except this PR makes the behavior global and default
@see #20547 which provides an explicit and robust way of caching
createSelector
has a big problem: it invalidates its cache way toofrequently. It does this whenever dependants change, but it's not
comparing those dependants against the called parameters - it's applying
them "globally" within the selector such that even when the underlying
data in
state
is the same, because the selector was invoked withdifferent parameters it generates different dependants and thinks things
are different.
This change caches the dependants per cache key so we don't need to
clear so often. This introduces memory bloat because we're storing those
cached values throughout the session.