insert / lookup multiple keys at once • We can insert all of the keys in a single transaction • If one fails, we have to fail them all in a single transaction
dedicated worker thread • That thread is the only thread to touch SQLite3 and processes items off the Queue • The queue is a list of "Operation to run + TaskCompletionSource to notify" • Bingo Bango, no concurrency problems
item and block if there is none 2. If we succeed, try to non-blocking fetch 31 more items at most 3. Create a transaction 4. Run all 32 commands 5. Drop the transaction, complete the associated Tasks
3. Read “Bar” 4. Read “Foo” 5. Read “Baz” 6. Delete “Bamf” { Bar: [Write Bar, Read Bar], Foo: [Read Foo, Read Foo], Baz: [Read Baz], Bamf: [Invalidate Bamf] } Group by the key, but maintain original order
Foo: [Read Foo, Read Foo], Baz: [Read Baz], Bamf: [Invalidate Bamf] } { Bar: [Write Bar, Read Bar], Foo: [Read Foo, Read Foo], Baz: [Read Baz], Bamf: [Invalidate Bamf] } Dedupe operations that do the same thing in a row
Foo: [Read Foo], Baz: [Read Baz], Bamf: [Invalidate Bamf] } 1. Read [Foo, Baz] 2. Write [Bar] 3. Invalidate [Bamf] Remove the First item in every list, and try to smush them together