Monitoring LocalStorage Size with AmplifyJS

115 views
Skip to first unread message

Ing. Haroldo Mario Diaz Peñaloza

unread,
Aug 24, 2013, 4:51:52 PM8/24/13
to ampl...@googlegroups.com
Hi Friends,

I write because I am developing an application using the AmplifyJS Framework for caching, but I need to know how to monitor as it changes the size of the browser memory so it can be cleaned when reaching its maximum storage, I would appreciate if you help me in this topic, and thank you very much.

Doug Neiner

unread,
Aug 26, 2013, 12:18:44 PM8/26/13
to ampl...@googlegroups.com
Hi there!

The limitations will vary depending on what method you are using. According to the Dive Into HTML5 article, the limit for localStorage is generally 5MB. You can read more about the limitations here: http://diveintohtml5.info/storage.html#limitations

In order to handle an out of storage space error, you would need to wrap your storage calls in a try catch. If you want to control what error is thrown, you can override amplify.store.error, but an error will be thrown – and it would be up to you to handle it, and clean up the storage.

I hope that helps!

Doug

On Saturday, August 24, 2013 at 3:51 PM, Ing. Haroldo Mario Diaz Peñaloza wrote:

Hi Friends,

I write because I am developing an application using the AmplifyJS Framework for caching, but I need to know how to monitor as it changes the size of the browser memory so it can be cleaned when reaching its maximum storage, I would appreciate if you help me in this topic, and thank you very much.

--
You received this message because you are subscribed to the Google Groups "Amplify" group.
To unsubscribe from this group and stop receiving emails from it, send an email to amplifyjs+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Scott González

unread,
Aug 26, 2013, 12:41:06 PM8/26/13
to ampl...@googlegroups.com
Actual limits can be seen at http://dev-test.nemikor.com/web-storage/support-test/

If you're just going to use a simple cache duration, just calling `amplify.store()` will purge expired caches (note that the performance of this is dependent on the number of values stored).
Message has been deleted

Douglas Neiner

unread,
Aug 26, 2013, 12:42:57 PM8/26/13
to ampl...@googlegroups.com
Thanks Scott. I looked for your document first, but couldn't locate it quickly. Thanks!

Doug

Sent from Mailbox for iPhone
Reply all
Reply to author
Forward
0 new messages