How many bytes does a webstorage key use?

Discussion and feedback on Construct 2

Post » Sun Mar 10, 2013 2:52 am

I'm using the webstorage object for a game I'm creating and I need to save ALOT of values, but I don't want to reach the 5mb limit.

Say I save 100 keys, how many bytes would that make?

Whats the maximum number of keys I can save before hitting the 5mb limit?JackieChan2013-03-10 02:52:53
B
10
S
4
G
6
Posts: 76
Reputation: 3,615

Post » Sun Mar 10, 2013 3:50 am

it depends a lot of things, the text values are extremely small than stored images, one character value is 2 or 4 bytes. 5 mb is more than 100 keys. Common c2runtime.js could be from 100kb to 500 kb more than 2000 lines of codes. I suppose the limits could be more than 100 keys.


There is one tip, if you save X position from instance, the value would be like 20.777756466 including decimals as default, to make it shorter, you could use int() expression to convert from float to integer, the value would be 20. Don't forget sometimes JSON syntax could add more characters each one stored value.


B
96
S
25
G
20
Posts: 3,055
Reputation: 22,644

Post » Sun Mar 10, 2013 3:04 pm

Assuming the browser internally uses UTF-8, you should be able to store 5 million characters of data, which includes characters from both keys and values. There is no key number limit.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Sun Mar 10, 2013 8:23 pm

thanks Ashley! 5 million characters is way more than enough.
B
10
S
4
G
6
Posts: 76
Reputation: 3,615

Post » Mon Mar 11, 2013 2:57 am

Doesn't the offline cache also use local webstorage?
B
24
S
4
G
1
Posts: 244
Reputation: 3,462

Post » Mon Mar 11, 2013 2:50 pm

@boolean - no, the offline cache is separate to WebStorage and doesn't contribute to the WebStorage quota.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580


Return to Construct 2 General

Who is online

Users browsing this forum: Aphrodite, Eisenhans and 12 guests