Skip to content

Slight changes to the CacheClient interface#253

Merged
froyo-np merged 3 commits intomainfrom
noah/more-generic-cache-client
May 5, 2026
Merged

Slight changes to the CacheClient interface#253
froyo-np merged 3 commits intomainfrom
noah/more-generic-cache-client

Conversation

@froyo-np
Copy link
Copy Markdown
Collaborator

@froyo-np froyo-np commented May 5, 2026

What

  • the shared priority cache is accessed via "clients" - these clients provide a way to check at runtime if content returned by the cache will satisfy the needs (enough data for the renderer to render something, for example). This function is now passed the request object, this makes this check much more polymorphic, allowing more re-use of cache-clients if the shape of data to be used changes a bit.
  • update the scatterbrain library's use of the cache client to not require regl directly
  • update the scatterbrain library's use of the cache client to use the new isValue check, to make it easy to change shader settings without requiring a new shader and a new cacheClient.

How

Replace this txt describing what kind of technical overlaying code changes were introduced here.

Screenshots

This section is optional if there are no visible changes

  • If possible add screenshots of the visible additions in the UI.
  • If there are changes in the UI, add Before and After Screenshots for quick overview.
  • If there was a Figma design, add a link to that here as well.
  • Hint : Drag and Drop any images you want to add to the PR. Also you can create a gif of an interactive version and add that!

PR Checklist

  • Is your PR title following our conventional commit naming recommendations?
  • Have you filled in the PR Description Template?
  • Is your branch up to date with the latest in main?
  • Do the CI checks pass successfully?
  • Have you smoke tested the example applications?
  • Did you check that the changes meet accessibility standards?
  • Have you tested the application on these browsers?
    • Chrome (Fully supported)
    • Firefox (Major bug fixes supported)
    • Safari (Major bug fixes supported)

froyo-np added 2 commits May 5, 2026 14:22
…st object - this makes it easier to build cache clients that are more flexible, which is nice for scatterbrain, as it is often the case that we rebuild a shader to bind different vertex buffers, but we'd like to keep using the same cache-client, as almost all the data is already there...
@froyo-np froyo-np requested a review from a team as a code owner May 5, 2026 21:28
@froyo-np froyo-np requested review from TheMooseman and chrisj May 5, 2026 21:28

export type ClientSpec<Item, ItemContent extends Record<string, Cacheable>> = {
isValue: (v: Record<string, Cacheable | undefined>) => v is ItemContent;
isValue: (v: Record<string, Cacheable | undefined>, item: Item) => v is ItemContent;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the api change - its non-breaking. All prior cache-clients that pass an isValue method that ignores the new argument are valid, will work at runtime, and will pass typechecking still.


type Content<V extends Cacheable> = Record<string, V>

export function buildScatterbrainCacheClient<V extends Cacheable>(
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nearly identical to the version that has been deleted from ./renderer.ts - this version is simply slightly more generic.
it does not need to know about regl, nor does it rely on a closure over the set of requested columns to validate its contents prior to serving up data.

}>;
type Content = Record<string, VBO>;

export function buildScatterbrainCacheClient(
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see cache-client.ts

@froyo-np froyo-np requested a review from Jarbuckle May 5, 2026 21:32
Copy link
Copy Markdown
Contributor

@TheMooseman TheMooseman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works on my machine, can't find anything to complain about

@froyo-np froyo-np merged commit 9326584 into main May 5, 2026
5 checks passed
@froyo-np froyo-np deleted the noah/more-generic-cache-client branch May 5, 2026 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants