本地存储和锁定

发布于 2024-10-09 06:51:01 字数 176 浏览 0 评论 0原文

由于 (html5) localStorage 及其等效项在选项卡和窗口之间持续存在,因此我考虑过使用它来传递消息。问题是获取和存储是不同的操作,因此不是原子的。我的模型依赖于 UUID 生成、冲突解决和信标来完成我需要做的一小部分工作,但我真正的问题是:

由于本地存储是共享内存资源,因此可用的锁定机制是什么?相互访问?

Since (html5) localStorage and its equivalencies persist in between tabs and windows, I've thought about using it for message passing. The problem is that fetch and store are different operations, and therefore not atomic. I have models that rely on UUID generation, conflict resolutions, and beaconing to do the small subset of what I need to do, but my real question is this:

Since the local storage is a shared memory resource, what are the locking mechanisms available for mutual access?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

萌︼了一个春 2024-10-16 06:51:01

Benjamin Dumke-von der Ehe 最近提出了一些 localStorage 的(实验性)锁定代码: http://balpha.de/2012/03/javascript-concurrency-and-locking-the-html5-localstorage/

更新:代码链接文章中的内容已损坏,但 Github 上 是代码,特别提到了该文章。

Benjamin Dumke-von der Ehe recently came up with some (experimental) locking code for localStorage: http://balpha.de/2012/03/javascript-concurrency-and-locking-the-html5-localstorage/

Update: the code link in the article is broken, but here on Github is code, specifically mentioning the article.

陈年往事 2024-10-16 06:51:01

我认为您真正需要的是 频道消息传递,尽管据我所知还没有人实现它。它允许脚本之间任意客户端消息传递。

I think what you really need is Channel Messaging, though as far as I'm aware no-one has implemented it yet. It allows arbitrary client side messaging between scripts.

む无字情书 2024-10-16 06:51:01

没有任何内置的。您必须想出自己的锁定机制。当然,您可以使用其他人为其他事情提出的任何现有方法(例如锁定内存缓存)。

There aren't any built-in. You'll have to come up with your own locking mechanism. You can off course use any of the existing methods that other people have come up with for other things (like locking in memcache for instance).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文