Provide Default Storage Cache

Created on 25 September 2023, over 1 year ago
Updated 27 April 2024, 8 months ago

Problem/Motivation

The example used by our default POC cache implementation uses a session storage cache. Making a utility like this available within the ApiClient package could be useful.

Since session storage is a browser utility, do we need to make any considerations for the server environment?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Fixed

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States brianperry

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

Merge Requests

Comments & Activities

  • Issue created by @brianperry
  • Status changed to Active about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States brianperry
  • πŸ‡ΊπŸ‡Έ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
  • Merge request !102Default cache β†’ (Merged) created by brianperry
  • Pipeline finished with Success
    9 months ago
    Total: 242s
    #136382
  • Pipeline finished with Success
    9 months ago
    Total: 236s
    #136385
  • πŸ‡ΊπŸ‡Έ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.

  • Pipeline finished with Success
    9 months ago
    Total: 224s
    #136462
  • Status changed to Needs review 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States brianperry
  • Pipeline finished with Success
    9 months ago
    Total: 237s
    #137471
  • Status changed to Needs work 9 months ago
  • Assigned to brianperry
  • πŸ‡ΊπŸ‡ΈUnited States brianperry

    That's a decent idea - I'll give it a shot.

  • Pipeline finished with Failed
    9 months ago
    Total: 214s
    #145362
  • Pipeline finished with Success
    9 months ago
    Total: 243s
    #145375
  • Status changed to Needs review 9 months ago
  • Pipeline finished with Success
    9 months ago
    Total: 515s
    #145777
  • Pipeline finished with Success
    9 months ago
    Total: 243s
    #145779
  • Issue was unassigned.
  • Status changed to Fixed 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States brianperry
  • Pipeline finished with Success
    9 months ago
    Total: 248s
    #145784
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024