Skip to content

Conversation

nikgraf
Copy link
Collaborator

@nikgraf nikgraf commented Jan 22, 2025

We store all decoded entities in a cache and for each query we reference the entities relevant to this query.
Whenever a query is registered we add it to the cache and add a listener to the query. Whenever a query is registered we remove the listener from the query.

Handling filters should be relatively straight forward as they are uniquely identified by their params.

Currently we only use one global cache for all entities.
In the future we probably want a build function that creates a cache and returns the
functions (create, update, findMany, …) that use this specific cache.

Open questions:

  • How do we handle findOne?
    Thoughts: Could be just a special case of findMany limited to a specific id or a separate mechanism.
  • How do we handle relations?
    Thoughts: We could have a separate query entry for each relation, but when requesting a lot of entities e.g. 1000 ly for a nesting one level deep it would result in a lot of cached queries. Not sure this is a good idea.

@nikgraf nikgraf changed the title add first draft entities cache Jan 22, 2025
@nikgraf nikgraf self-assigned this Jan 22, 2025
@nikgraf nikgraf force-pushed the entities-cache branch 3 times, most recently from 51f5009 to 533a620 Compare January 24, 2025 06:59
@nikgraf nikgraf marked this pull request as ready for review January 24, 2025 07:02
@nikgraf nikgraf requested a review from fubhy January 24, 2025 07:03
@nikgraf nikgraf force-pushed the entities-cache branch 4 times, most recently from 51f4596 to 75d33e0 Compare February 12, 2025 16:05
@nikgraf nikgraf merged commit be987c9 into main Mar 7, 2025
4 checks passed
@nikgraf nikgraf deleted the entities-cache branch March 7, 2025 16:07
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.

1 participant