【问题标题】:In a Session Storage key value pair, is there a character limit to the length of the value string?在会话存储键值对中,值字符串的长度是否有字符限制?
【发布时间】:2021-09-13 18:56:59
【问题描述】:

我有一个数据超过 5MB 的对象。我正在使用 pako 将数据压缩到大约 1.7MB。然后我尝试将压缩数据存储到会话存储中。对于较小的对象,这很好用,但是对于这个较大的对象,我超出了配额。考虑到我计算的数据大小低于 5MB,我想知道会话存储中可以存储的内容是否还有其他限制,例如值的字符串长度或 Uint8Array 的字节长度。

cachedLookups = {
  ... //Tons of data
};
const stringifiedLookups = JSON.stringify(this.cachedLookups)
const compressedLookups = pako.deflate(stringifiedLookups);
sessionStorage.setItem(this.sessionStorageKey, compressedLookups);

【问题讨论】:

    标签: javascript compression session-storage pako


    【解决方案1】:

    找到了答案。 Is there a limit to the key length for localStorage?之前已经回答了这个问题

    对于具有单个键值对的 SessionStorage,没有字符限制,除非键字符串和值字符串的组合数据大小不超过 Storage 的 ~5MB 限制。

    【讨论】:

      猜你喜欢
      • 2012-11-09
      • 2012-11-02
      • 2017-04-02
      • 2018-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-19
      相关资源
      最近更新 更多