Electron IndexedDb 限制?

标签 electron indexeddb

this Electron issue ,@zcbenz 评论道:

We have the same size limitation with Chrome browser, which is '1/3 of the of available disk space'.

该回复来自 2016 年初。

我运行了这段代码:

const estimation = await navigator.storage.estimate();
console.log(`Quota: ${estimation.quota}`);
console.log(`Usage: ${estimation.usage}`); 

它告诉我,我有 100% 的可用磁盘空间作为我的配额,所以我很困惑,找不到比 2016 年评论更新的内容,这也是特定于 Electron 的。

所以我的问题:

  • 这是否已正式更改?
  • 如果您尝试超出该限制(假设并非真正 100% 的可用空间),会发生什么情况?
  • Electron/Chromium 会驱逐您的数据吗?

--- Electron v3.0.4

最佳答案

2019 年,我可以向您保证,您现在可以完全控制您的索引数据库数据。
根据谷歌的这篇文章: https://developers.google.com/web/updates/2017/08/estimating-available-storage-space
上面的代码应返回正确的配额大小。
但除此之外,现在调用此代码会使您的数据无法被“驱逐”

if (navigator.storage && navigator.storage.persist)
  navigator.storage.persist().then(function(persistent) {
    if (persistent)
      console.log("Storage will not be cleared except by explicit user action");
    else
      console.log("Storage may be cleared by the UA under storage pressure.");
  });

https://developer.mozilla.org/en-US/docs/Web/API/StorageManager/persist

关于Electron IndexedDb 限制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52921552/

相关文章:

javascript - 如何使用 idbKeyval 获取我的 IndexedDB val 的 key ?

reactjs - 如何在 src 文件夹之外要求具有反应 Electron 的图像(应用程序支持)

react-router - 如何在Electron中使用 `react-router`从组件外部布线?

node.js - Electron - 如何在 Electron 应用程序中使用 ffmpeg

javascript - 使用 Dexie.js 编写多个 where 条件

indexeddb - IDBKeyRange.only 在 IE 中的复合索引上

javascript - 如何使用 Electron 重新加载忽略多个目录和文件

javascript - 当在Electron中使用时,的page.evaluate()总是返回空对象

javascript - 我应该每次打开一个 IDBDatabase 还是保持一个实例打开?

indexeddb - 在 IndexedDB 中检查 .delete() 是否成功