Skip to content

updating cache on referch with disableCache: true #32

@fantasybdcricket

Description

@fantasybdcricket

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions