kinto.js
kinto.js copied to clipboard
Perform the whole sync (pull + push) within a single transaction
So we can abort the whole import process on error, avoiding leaving the db in an inconsistent state.
Not sure if this is relevant here, but just wanted to mention how important batching together writes to IndexedDB is, for performance. This is also a topic in localForage, we are trying to do automatic batching of writes there. The basic principle of that is:
- you add or update one record -> it starts updating IndexedDB
- you add or update more records -> it queues them up until IndexedDB is idle
- the first transaction completes -> it creates a new batch transaction from everything that was added to the queue in the meantime
After a quick discussion with @ametaireau, here's the current state of our thinking on this:
- Having transactions would provide a neat way to cancel local persistence operations;
- It would also improve performances on large batches of persistence operations;
- localStorage adapter would need a specific manually implemented solution to cover all the use cases;
- We should heavily challenge if we actually need this feature: for now, nobody has explicitly expressed a need for it;
- We should also discuss this with @leplatrem which I remember was having opinions on the matter.
Thoughts?
#303 has now landed and is a huge step towards this goal.
When https://bugzilla.mozilla.org/show_bug.cgi?id=1193394 will land in Firefox, it will be possible to have IndexedDB transactions across promises in Chrome+Firefox.
That's it! It landed!
Firefox 60 supports promises within IndexedDB transactions \o/
There is a lot of things that could be simplified, quite a huge amount of work.
Wow! :)