- Issue created by @brianperry
- Status changed to Active
about 1 year ago 6:18pm 1 November 2023 - πΊπΈUnited States brianperry
Spent some time thinking about ways to accomplish this and am not yet convinced there is a solution that makes sense. Most options are either a dependency, or aren't universal (as in won't run on both the server and client).
I'm not convinced that selecting and bundling a dependency makes sense for the base API Client. I think we're better off showing how our cache works with common options rather than hitching our wagon to something specific.
Things like the session storage API or the cache API could meet the need here, but as I understand it they are both browser APIs. We might want to document these options, but I think shipping with a default option that only works client side (or vice versa) is too confusing.
Keeping this open for now, but my current thinking is that we work on documenting real world cache examples and postpone or close this if we're satisfied. We can then let user feedback dictate if we need to change course and ship with something.
I agree that ideally we would find something that works cross platform here but I'm not sure it exists.
If we really wanted to provide something out of the box, I think we could cook something up that uses indexedDB, cache, or local/session storage APIs in the browser, and an in-memory or file based solution for server side. The code could check the environment before selecting which to save the data to.
I wonder if a plugin system would be worth adopting? Maybe for 2.0 :)
Keeping this open for now, but my current thinking is that we work on documenting real world cache examples and postpone or close this if we're satisfied. We can then let user feedback dictate if we need to change course and ship with something.
That seems reasonable.
- πΊπΈUnited States brianperry
Working on the docs for caching I came to the conclusion that without some kind of default cache option this is way too hard to write about (and probably use.) So I'm breaking down and creating a default cache utility which will be available to use, but not included on the client class by default. Currently using the 'nanostores' package to solve this, which is a single small dependency (and itself has zero dependencies.) Our cache interface helps here as well - should be possible to change the underlying cache without breaking changes if we want to.
- Status changed to Needs review
8 months ago 2:26pm 4 April 2024 - Status changed to Needs work
8 months ago 6:28pm 5 April 2024 - Assigned to brianperry
- πΊπΈUnited States brianperry
That's a decent idea - I'll give it a shot.
- Status changed to Needs review
7 months ago 12:53am 13 April 2024 MR to the MR is up for review: https://git.drupalcode.org/issue/api_client-3389583/-/merge_requests/1
- Issue was unassigned.
- Status changed to Fixed
7 months ago 3:30pm 13 April 2024 Automatically closed - issue fixed for 2 weeks with no activity.