Closed alexgleason closed 1 year ago
Yes, you are correct that db.transaction
can achieve the same benefits and guarantees. However, with versioning, the version checks and conditional writes can be performed entirely in a separate worker writer thread, whereas db.transaction
requires that the writer thread enqueue an event on the main JS thread and execute the transaction on the main JS thread. Therefore, using versioning has better performance and concurrency than using db.transaction
.
db.put the wrong version
This (the returned promise) will resolve to false.
Thank you. That is extremely helpful!
I want to store a JSON object as a value in LMDB. Later I want to update values inside it, while there are multiple processes potentially trying to do the same thing, without race conditions.
After reading through the README, the explanation on Concurrency and Versioning made sense as a solution (although I still don't know what happens when you
db.put
the wrong version - the function throws?)But according to the README,
db.transaction
can achieve same benefits and guarantees without all the hassle of versioning. Is that really true?