jakearchibald / idb-keyval

A super-simple-small promise-based keyval store implemented with IndexedDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: Does it support several simultaneous read/write operations?

alexiusp opened this issue · comments

I have a small question.

I am reading/writing from/to the database from different parts of my code asynchronously and it might happen simultaneously. Or at least new operation might start before previous operation has completed. What will happen in this case? Will new request fail or wait until previous operation completes or it is possible to do it simultaneously?

Reads can happen in parallel with other reads. A write operation locks the underlying store until the write is complete, during which other reads and writes will queue.

Reads and writes are seperate transactions, which is why there's a specific method for update, which performs the read and the write in the same transaction https://github.com/jakearchibald/idb-keyval#update.

If you need more control over transactions, you can get that with https://www.npmjs.com/package/idb.