Skip to content
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

updating cache on referch with disableCache: true #32

Open
fantasybdcricket opened this issue Jan 19, 2020 · 0 comments
Open

updating cache on referch with disableCache: true #32

fantasybdcricket opened this issue Jan 19, 2020 · 0 comments

Comments

@fantasybdcricket
Copy link

fantasybdcricket commented Jan 19, 2020

I'm trying to find a way to invalidate cache for an individual item which looks like is not possible at the moment. For example if I have an api like:

const API = {
   user: {
     path: 'user/:userId'
   }
} 

When I call api.get('user', {pathParameters: {userId: 'user1'}}) it will cache the response for user1. But at some point if user1 is updated and I want to invalidate cache only for user1 there is no way, I would have to clear the cache for all the users with clearCache('user'), if I understant correctly. Now I see that api.get() also allows you to override disableCache for a particular call. So technically I can re-fetch user1 with api.get('user', {pathParameters: {userId: 'user1'}, disableCache: true }) and get the latest values for user1.

I was assuming that the api would now update the existing cache for user1 to the latest value that it received in the seconds call. But looks like it doesn't. It would be neat if that was the case! Ootherwise next time I call api.get for user1 without disableCache again, I would be getting older version of the user that was returned in the first call.

I can shoot a PR if you think this makes sense to have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant