You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
constAPI={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.
The text was updated successfully, but these errors were encountered:
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:
When I call
api.get('user', {pathParameters: {userId: 'user1'}})
it will cache the response foruser1
. But at some point ifuser1
is updated and I want to invalidate cache only foruser1
there is no way, I would have to clear the cache for all the users withclearCache('user')
, if I understant correctly. Now I see thatapi.get()
also allows you to overridedisableCache
for a particular call. So technically I can re-fetchuser1
withapi.get('user', {pathParameters: {userId: 'user1'}, disableCache: true })
and get the latest values foruser1
.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 callapi.get
foruser1
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.
The text was updated successfully, but these errors were encountered: