即使保存的数据不变,IndexedDB的大小仍在增长 [英] IndexedDB size keeps growing even though data saved doesn't change

查看:318
本文介绍了即使保存的数据不变,IndexedDB的大小仍在增长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Redux Persist

I am using Redux Persist and LocalForage in my web application. I have a series of actions that are fired upon login that update some data about the user. The IndexedDB size after all actions are fired and the data is saved in the JSON format on indexedDB is ~1.4Mb.

但是,即使IndexedDB 请勿内的值发生更改,我是否刷新页面从而再次触发操作,还是注销并重新登录(我已经使用JSON diff工具进行了两次检查) ,存储空间不断增长.最终,Chrome会在增长几MB后清除掉其中的一部分,但不会恢复到最初的正确大小.

However if I refresh the page thus triggering again the actions, or if log out and back in, even though the values inside IndexedDB DO NOT change (I have double checked with a JSON diff tool), the size of the storage keeps on growing. Eventually Chrome will clear some of it after it grows for a few MBs, but not going back to the initial correct size.

IndexedDB JSON完全相同,没有任何区别,但是大小存在很大差异.有谁知道为什么会这样,我该如何预防呢? 我还想知道Chrome何时/多久清除一次使我的IndexedDB混乱的数据,但是我找不到任何参考.

The IndexedDB JSON is exactly the same, no differences whatsoever, but huge difference in size. Does anyone know why this is happening and how can I prevent it? I also would like to know when/how often Chrome clears whatever data it is that is cluttering my IndexedDB, but I haven't been able to find any reference for it.

非常感谢

推荐答案

Chrome使用LevelDB作为索引DB的后备存储.您可以在以下位置了解有关LevelDB的更多信息: https://github.com/google/leveldb

Chrome uses LevelDB as a backing store for Indexed DB. You can read more about LevelDB at: https://github.com/google/leveldb

LevelDB已针对快速读写进行了优化.通过压缩懒散地回收空间.

LevelDB is optimized for fast reads and writes. Space is lazily reclaimed through compaction.

这篇关于即使保存的数据不变,IndexedDB的大小仍在增长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆