Locking model for IndexedDB?

ぐ巨炮叔叔 提交于 2021-01-18 05:20:01

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/5518692/locking-model-for-indexeddb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!