[英]What local storage in html5 can I use safely in the browser ui thread and the web worker thread
I've been trying to use web sql database api in webkit based browsers. 我一直在尝试在基于webkit的浏览器中使用web sql数据库api 。 I have been using the async api in the main ui thread and a web worker .
我一直在主ui线程和web worker中使用async api 。 Both threads access the same database (which as you know is sqlite underthehood)
两个线程都访问同一个数据库(你知道这是sqlite的继承)
Everything behaves fine but occassionally transactions are lost or one transaction fails and it seems to be a timing/race condition. 一切都表现良好,但偶尔交易丢失或一次交易失败,似乎是时机/竞争条件。 It appears access to the underlying sqlite database is not thread-safe.
似乎对底层sqlite数据库的访问不是线程安全的。
A bit more background. 多一点背景。 My web worker is simply executing a query against a table that may have a record inserted into it from the main ui thread.
我的Web工作者只是对一个表执行查询,该表可能从主ui线程中插入了一条记录。
I am wondering if it is actually documented somewhere what local/web storage can be accessed safely from both the ui thread and the web worker thread? 我想知道是否实际记录了哪些本地/网络存储可以安全地从ui线程和Web工作线程访问? I've read somewhere that the indexeddb api is thread safe but that does not help me right now since browser support for it is poor/non-existent for the browsers I am targeting (at least I think so - I get my information from http://caniuse.com )
我已经读过某个地方, indexeddb api是线程安全的,但是这对我来说没有帮助,因为浏览器支持它对于我所针对的浏览器来说很差/不存在(至少我是这么认为的 - 我从http获取我的信息) ://caniuse.com )
Any insights would be gratefully received 任何见解都会感激不尽
You can't use localStorage or sessionStorage from WebWorkers. 您不能使用WebWorkers的localStorage或sessionStorage。
While both are synchronous operations they aren't a real issue for simple data writing and reading. 虽然两者都是同步操作,但它们不是简单数据写入和读取的真正问题。 The issue is more relevant at browser start-up, but that's a browser implementation issue.
这个问题在浏览器启动时更具相关性,但这是一个浏览器实现问题。
Take a look at this, it should help: http://www.nczonline.net/blog/2012/04/25/the-performance-of-localstorage-revisited/ 看看这个,它应该有所帮助: http : //www.nczonline.net/blog/2012/04/25/the-performance-of-localstorage-revisited/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.