Provide a Way to Invalidate Cache

Created on 29 November 2023, 7 months ago
Updated 5 May 2024, about 2 months ago

Problem/Motivation

We're working on introducing an option to disable the cache for individual get requests. This made me think that we may also want to have a way to update the cache with the result of a new fetch.

Looking for a comparable API I found that Apollo Client has an evict method. Might be worth looking for a few alternatives, but on first glance this seems like a decent approach.

And having an evict method would make something like a 'refresh' request much easier. I think that should probably be a follow up issue though.

Steps to reproduce

* Make a cached request.
* You're stuck with it forever :) Technically it might be possible to use cache.set to remove an entry, but we can provide a better API than that.

Proposed resolution

* Update the API Client Cache Type to include an optional `evict` method that accepts a key as a parameter.
* Update the defaultCache implementation in the utilities package to include an evict method. This method will remove the value stored at the provided cache key.

Remaining tasks

* Implement changes to ApiClient types.
* Implement changes to defaultCache in utilities package.
* Add test coverage.
* Update documentation.

API changes

* Cache interface will accept an optional evict method.

✨ Feature request
Status

Active

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States brianperry

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024