-
-
Save thexande/b43a77daf0f43fa8d2a16741386fd248 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@testable import Apollo | |
final class InMemoryNormalizedCache: NormalizedCache { | |
private var records: RecordSet | |
init(records: RecordSet = RecordSet()) { | |
self.records = records | |
} | |
func loadRecords(forKeys keys: [CacheKey]) -> Promise<[Record?]> { | |
let records = keys.map { self.records[$0] } | |
return Promise(fulfilled: records) | |
} | |
func merge(records: RecordSet) -> Promise> { | |
return Promise(fulfilled: self.records.merge(records: records)) | |
} | |
func clear() -> Promise { | |
records.clear() | |
return Promise(fulfilled: ()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment