IndexedDB的锁定模型? [英] Locking model for IndexedDB?

查看:64
本文介绍了IndexedDB的锁定模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IndexedDB如何处理正在处理异步事务的多个选项卡?事务是否会完全锁定所有相关的对象存储?我该如何保证,如果一个选项卡正在处理一条数据,而另一个选项卡却没有做同样的事情?

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?

推荐答案

IndexedDB规范确定如果多个READ_WRITE事务正在尝试访问同一对象存储(即,如果它们具有重叠的作用域),则首先创建的事务必须是首先访问对象存储的事务.由于上一段中的要求,这也意味着它是唯一可以访问对象存储的事务,直到事务完成为止."

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."

这意味着,当事务处于READ_WRITE模式时,objectStore将被锁定以进行其他READ_WRITE事务,直到事务完成为止.

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.

您可以从此处了解更多有关IndexedDB事务模式的信息- http://www.w3.org/TR/IndexedDB/#dfn-mode

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

吉尔

这篇关于IndexedDB的锁定模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆