简体   繁体   English

在 Chrome 浏览器中使用 indexedDB 时有大小限制吗?

[英]is there any size limit when using indexedDB in chrome browser?

i'm working on caching objects as JSON and i saw that indexedDB is a great place to do it but i'm wondering that if it has a size limit我正在将对象缓存为 JSON,我看到 indexedDB 是一个很好的地方,但我想知道它是否有大小限制


  • is there any limit for indexedDB? indexedDB 有什么限制吗?

  • if it has,how can make it unlimited?如果有,如何使其不受限制?


i'm using vanilla javascript我正在使用香草 javascript

thanks a lot多谢

As per the documentation , Chrome will reserve 1/3 of the disk for offline storage.根据文档,Chrome 会保留 1/3 的磁盘用于离线存储。 This means if a disk is 99GB large, Chrome will reserve 33GB of storage for offline storage.这意味着如果磁盘大小为 99GB,Chrome 将为离线存储保留 33GB 的存储空间。 I would imagine if the usable space is less than that that Chrome adjusts however much it claims to suit.我可以想象,如果可用空间小于 Chrome 声称适合的调整量。

If an origin is not used often, in cases where the disk is running out of space, Chrome will delete an entire origins' offline storage.如果一个源不经常使用,在磁盘空间不足的情况下,Chrome 会删除整个源的离线存储。 An origin can claim a maximum of 20% of the pool that Chrome has, meaning that on the aforementioned disk with 33GB of storage allocated to Chrome, you can only use 6.6GB of storage.一个来源最多可以申请 Chrome 拥有的池的 20%,这意味着在上述分配给 Chrome 的 33GB 存储空间的磁盘上,您只能使用 6.6GB 的存储空间。

It's recommended though that you don't rely on having a lot of storage to play with.但建议您不要依赖大量存储空间。 You should handle cases where Chrome denies you the ability to write offline storage, just like with any other app.您应该处理 Chrome 拒绝您写入离线存储的情况,就像处理任何其他应用程序一样。 Chrome will let you know when you attempt to write to offline storage, that you're out of storage.当您尝试写入离线存储空间时,Chrome 会通知您存储空间不足。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM