-
Notifications
You must be signed in to change notification settings - Fork 737
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
Split Caching review and thoughts #3377
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,14 +7,14 @@ public protocol NormalizedCache { | |
/// - Parameters: | ||
/// - key: The cache keys to load data for | ||
/// - Returns: A dictionary of cache keys to records containing the records that have been found. | ||
func loadRecords(forKeys keys: Set<CacheKey>) throws -> [CacheKey: Record] | ||
func loadRecords(forKeys keys: Set<CacheKey>, identifier: UUID?) throws -> [CacheKey: Record] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering why you need the identifier added to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The goal was to use it in the custom implementation, but as pointed out, will mostly not need this and will remove. |
||
|
||
/// Merges a set of records into the cache. | ||
/// | ||
/// - Parameters: | ||
/// - records: The set of records to merge. | ||
/// - Returns: A set of keys corresponding to *fields* that have changed (i.e. QUERY_ROOT.Foo.myField). These are the same type of keys as are returned by RecordSet.merge(records:). | ||
func merge(records: RecordSet) throws -> Set<CacheKey> | ||
func merge(records: RecordSet, identifier: UUID?) throws -> Set<CacheKey> | ||
|
||
/// Removes a record for the specified key. This method will only | ||
/// remove whole records, not individual fields. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a problem here. You could theoretically use the
subscript
to addpendingLoads
with one identifier, and then callload
with a differentidentifier
, which would then run the batch load the the second identifier, even for thependingLoads
that should use the other identifier.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh good catch, although I was able to fix this and get all the tests to pass by separating identifier loads vs non identifier loads by hashing the identifier with the cache key internal to the loader, kinda started to question whether this was all really needed when reading the cache as you pointed out.