redux-toolkit
redux-toolkit copied to clipboard
Feature request: provide tags to not invalidate by
Here is the scenario:
I have a dashboard that changes based on two arguments, list1 and list2.
Each different combination of the lists will create a new unique cache entry. Even if both lists only have 10 items each, that's still a crazy number of different potential cache combinations.
The issue comes when I want to patch one specific cache with new data (the current one in view) but also invalidate any other caches that may be affected by that change.
Patching the specific cache A is fine, I know the combination of the two lists to do this.
But invalidating every other cache excluding A is currently impossible. I only know what cache key combination NOT to invalidate. The opposite would require knowing every other combination of cache keys, which is huge.
My proposal is to add a second argument to api.util.invalidateTags(tagsToInvalidate, tagsToExclude)
Any tags in tagsToExclude
would skip the cache even it had matching tags in tagsToInvalidate
.
That way I could use a broad tag to capture all caches and then use a specific tag (the cache key string) to exclude that one cache.
- Is this viable solution at all?
- Has anyone else experienced this problem?
- Are there any other ways to solve it?
Thanks you for your time 🙏