9

我试图弄清楚使用 localStorage 是否比 redis 更好地存储不会超过 localStorage 5MB 限制的数据集。在我正在实施的网站中,计划是当最终用户访问任何页面时,检查用户是否将最新数据存储在 localStorage 中。如果没有,则刷新它。

通过这种方式,用户不需要去像redis这样的外部数据存储,这应该会更快。

我在网上找不到任何可以回答这个问题的资源。我不确定原因是否是因为我以错误的方式去做。

谢谢你的帮助!

4

2 回答 2

5

我会说你没有找到这个问题的任何答案的一个原因可能是因为 Redis 不应该在浏览器中使用......

考虑到 localStorage 是一种浏览器工具,它无法与 Redis 相提并论。Redis 为后端提供远程存储。它不应该暴露在 Internet 上,而是部署在受信任的网络上(就像许多其他 NoSQL 存储一样)。

IMO你在这里比较苹果和橘子......

于 2013-02-15T18:01:53.990 回答
4

@Didier or anyone else ...

What if the webapp is on a trusted company network? How would you answer it then? Because the same question as OP has crossed my mind.

Redis is simply a cached service to speed up data access. So the question is, when one is considering the use of Redis on a intra company web app, then does it may make sense to use Local Storage as the cache, instead of Redis, to speed data access. That is the root of the question.

EDIT: found something interesting BankersBox - Mimics Redis api and uses local storage as the persistent data store. https://github.com/twilio/BankersBox

于 2014-09-09T22:47:34.590 回答