在浏览器中使大型IndexedDB持久化

时间:2022-05-09 22:51:23

I am looking at making a LOB html5 web application. The main part we are trying to accomplish is to make the application offline capable. This will mean taking a large chunk of SQL data from the server and storing it in the browser. This will need to be living in the browser for quite a while, dont want to have to continuously refresh it everytime the browser is closed and reopened.

我正在寻找制作LOB html5 Web应用程序。我们要完成的主要部分是使应用程序脱机。这意味着从服务器中获取大量SQL数据并将其存储在浏览器中。这需要在浏览器中存在很长一段时间,不希望每次关闭和重新打开浏览器时都要不断刷新它。

We are looking at storing the data inside the client in indexedDB but I read that indexedDB is stored in temporary storage so the lifetime of it cannot be relied on. Does anyone know of any strategies on prolonging its lifetime? Also we will be pulling down massive chunks of data so 1-5mb storage might not suffice what we require.

我们正在考虑将数据存储在indexedDB中的客户端内,但我读到indexedDB存储在临时存储中,因此不能依赖它的生命周期。有谁知道延长其寿命的任何策略?此外,我们将删除大量数据,因此1-5mb存储可能不足以满足我们的要求。

My current thought is to somewhat store it down to the browser storage using html5 storage API's and hydrate it into the indexedDb as it's required. Just need to make sure we can grow the storage limit to whatever we need.

我目前的想法是使用html5存储API将其存储到浏览器存储中,并根据需要将其水合到indexedDb中。只需要确保我们可以将存储限制增加到我们需要的任何内容。

Any advice on how we approach this?

关于我们如何处理此事的任何建议?

3 个解决方案

#1


1  

We are looking at storing the data inside the client in indexedDB but I read that indexedDB is stored in temporary storage so the lifetime of it cannot be relied on.

我们正在考虑将数据存储在indexedDB中的客户端内,但我读到indexedDB存储在临时存储中,因此不能依赖它的生命周期。

That is technically true but in practice I've never seen the browser actually delete data. More common if you're storing a lot of data, you will hit quota limits which are annoying and sometimes inconsistent/buggy.

这在技术上是正确的,但实际上我从未见过浏览器实际删除数据。更常见的是,如果您存储大量数据,您将达到配额限制,这些限制很烦人,有时会出现不一致/错误。

Regardless, you shouldn't rely on data in IndexedDB always being there forever, because users can always delete data, have their computers break without backups, etc.

无论如何,你不应该依赖IndexedDB中永远存在的数据,因为用户总是可以删除数据,让计算机在没有备份的情况下中断等等。

#2


0  

If you create a Chrome extension, you can enable unlimited storage. I've successfully stored several thousand large text documents persistently in indexedDB using this approach.

如果您创建Chrome扩展程序,则可以启用无限存储空间。我已经使用这种方法成功地在indexedDB中存储了数千个大型文本文档。

#3


0  

This might be a silly question to add, but can you access the storage area outside of the browser? For instance, if I did not want to have a huge lag when my app starts up and loads a bunch of data, could I make an external app to "refresh" the local data so that when the browser starts, it is ready to rock and roll?

这可能是一个愚蠢的问题,但您可以访问浏览器之外的存储区域吗?例如,如果我不希望在我的应用程序启动并加载大量数据时出现巨大延迟,我是否可以创建一个外部应用程序来“刷新”本地数据,这样当浏览器启动时,它就可以摇滚了和滚?

I assume the answer here will be no, but I had to ask.

我认为这里的答案是否定的,但我不得不问。

Has anyone worked around this for large data sets? For instance loading in one tab and working in another? Chrome extension to load, but access via the app?

有没有人为大型数据集解决这个问题?例如,在一个标签中加载并在另一个标签中工作? Chrome扩展程序要加载,但可以通过应用程序访问?

#1


1  

We are looking at storing the data inside the client in indexedDB but I read that indexedDB is stored in temporary storage so the lifetime of it cannot be relied on.

我们正在考虑将数据存储在indexedDB中的客户端内,但我读到indexedDB存储在临时存储中,因此不能依赖它的生命周期。

That is technically true but in practice I've never seen the browser actually delete data. More common if you're storing a lot of data, you will hit quota limits which are annoying and sometimes inconsistent/buggy.

这在技术上是正确的,但实际上我从未见过浏览器实际删除数据。更常见的是,如果您存储大量数据,您将达到配额限制,这些限制很烦人,有时会出现不一致/错误。

Regardless, you shouldn't rely on data in IndexedDB always being there forever, because users can always delete data, have their computers break without backups, etc.

无论如何,你不应该依赖IndexedDB中永远存在的数据,因为用户总是可以删除数据,让计算机在没有备份的情况下中断等等。

#2


0  

If you create a Chrome extension, you can enable unlimited storage. I've successfully stored several thousand large text documents persistently in indexedDB using this approach.

如果您创建Chrome扩展程序,则可以启用无限存储空间。我已经使用这种方法成功地在indexedDB中存储了数千个大型文本文档。

#3


0  

This might be a silly question to add, but can you access the storage area outside of the browser? For instance, if I did not want to have a huge lag when my app starts up and loads a bunch of data, could I make an external app to "refresh" the local data so that when the browser starts, it is ready to rock and roll?

这可能是一个愚蠢的问题,但您可以访问浏览器之外的存储区域吗?例如,如果我不希望在我的应用程序启动并加载大量数据时出现巨大延迟,我是否可以创建一个外部应用程序来“刷新”本地数据,这样当浏览器启动时,它就可以摇滚了和滚?

I assume the answer here will be no, but I had to ask.

我认为这里的答案是否定的,但我不得不问。

Has anyone worked around this for large data sets? For instance loading in one tab and working in another? Chrome extension to load, but access via the app?

有没有人为大型数据集解决这个问题?例如,在一个标签中加载并在另一个标签中工作? Chrome扩展程序要加载,但可以通过应用程序访问?