-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature request: loadByCompositeKeyAsync #201
Comments
Previously discussed in #123 (comment) |
Thinking about this, let's say we have an entity definition where an entity is unique name per account:
Before composite keys:
After composite key on (account_id, name), additional invalidations needed for above scenario (need to come up with some mechanism for cache key creation that ensures no conflicts based on field values). There'd also be a composite dataloader for each composite key:
I think this might be fairly straightforward. But hard to know. It'd be good to spend some time coming up with an edge case. |
Okay, got this implemented on a branch: main...@wschurman/03-21-chore_refactor_common_adapter_loading_and_caching Planning to reorder the PRs to ease review, but the general approach is to genericize the keys/values interface for the batched/cached pipeline (data manager -> cache adapter -> database adapter). To do this, we need to add a "holder object" concept that both single-field and composite-field loads/invalidations implement. And then to make the holders work in existing code, we need to make them "hashable" in the sense that we need to override equality for the relevant internal operations, which turn out to mostly be using these holders in Maps as keys. So, concretely the plan is:
|
…te keys (#269) # Why This adds the utility classes needed for composite field loading as described in #201. # How This adds a few concepts: - `areSetsEqual` - simple utility for checking set equality - `SerializableKeyMap` - a map where keys must be of a custom interface for checking equality. # Test Plan Add new tests, run them. Full coverage.
# Why Step 2 of #201. This PR abstracts out (genericizes) the load key and load value interfaces for batched/cached loading in preparation for composite field loading. # How Accomplishing this requires a number of things: 1. A set of interfaces for the keys and load values to be used to load entity field objects. 2. A concrete implementation of that interface for the current use case (single fieldName, fieldValue(s)). 3. Data structure changes in the adapters and data manager to handle the new key type not being comparable via `===`. (see base PR for new map data structure for using these objects as keys). 4. Updates to the test matchers to know how to compare the serializable holder objects. # Test Plan Update a number of tests and add a few new tests. This has full coverage.
https://github.com/expo/universe/pull/10823/files#r1020707597
The text was updated successfully, but these errors were encountered: