HTML5 localStorage的最大大小是否包含键名? [英] Does HTML5 localStorage maximum size include key names?

查看:361
本文介绍了HTML5 localStorage的最大大小是否包含键名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTML5的localStorage WebStorage最大大小为5MB。

HTML5's localStorage WebStorage has a maximum size of 5MB.

这是否包含密钥名称?

例如,如果我使用密钥名称非常长的密钥名称而且这只是1而不是key1,我会早点用完空间吗?

For instance, if I were to use key names "quite-a-long-key-name-and-this-is-only-1" instead of "key1", would I run out of space sooner?

关于一个稍微相关的话题;是否存在命名localStorage密钥的事实约定?
使用第三方JS脚本时如何防止名称空间冲突?

On a slightly related topic; is there any de-facto convention for naming localStorage keys? How are namespace collisions prevented when using third party JS scripts?

推荐答案


这是否包括密钥名称?

Does this include the key names?

是的,它们成为数据的一部分,例如它们识别您存储的数据,然后检索以便获取也可以保存。

Yes those do, they become part of data eg they identify data you store and later retrieve so that got to be saved as well.


使用第三方JS
脚本时如何防止名称空间冲突?

How are namespace collisions prevented when using third party JS scripts?

这是一个很好的问题,我通常在localStorage中加上应用程序名称的前缀。虽然更好的方法是创建哈希,例如某些算法接受类似应用程序名称的字符串等,稍后在阅读时再次使用它们。

That's a good question, I generally prefix localStorage with application name. Though a better approach would be to create a hash eg some algorithim that accepts a string like application name, etc and later when reading you use them again.

这篇关于HTML5 localStorage的最大大小是否包含键名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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