最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Locking model for IndexedDB? - Stack Overflow

programmeradmin0浏览0评论

How does IndexedDB handle multiple tabs each with asynchronous transactions in-flight? Do transactions lock all of the related object stores entirely? How can I guarantee that if one tab is working on a piece of data that another isn't doing the same thing?

How does IndexedDB handle multiple tabs each with asynchronous transactions in-flight? Do transactions lock all of the related object stores entirely? How can I guarantee that if one tab is working on a piece of data that another isn't doing the same thing?

Share Improve this question edited Feb 5, 2020 at 2:02 Michael Ramos 5,8178 gold badges40 silver badges54 bronze badges asked Apr 1, 2011 at 20:48 Ben DiltsBen Dilts 10.7k18 gold badges60 silver badges86 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 19

The IndexedDB specifications determine that "If multiple READ_WRITE transactions are attempting to access the same object store (i.e. if they have overlapping scope), the transaction that was created first must be the transaction which gets access to the object store first. Due to the requirements in the previous paragraph, this also means that it is the only transaction which has access to the object store until the transaction is finished."

That means that when a transaction is in a READ_WRITE mode the objectStore will be locked for other READ_WRITE transactions up until the transaction will finish.

You can read more about the IndexedDB transaction modes from here - http://www.w3.org/TR/IndexedDB/#dfn-mode

Gil

发布评论

评论列表(0)

  1. 暂无评论