Any solution for key-value local storage?


#1

Hi all,

I’d like to know is there any solution for key-value local storage in client-side? LocalStorage dose work, but I have large data to read and write, I got this error from browser:

Error: Setting the value of ‘APPNAME’ exceeded the quota.

when executing:

window.localStorage[‘APPNAME’] = angular.toJson(VARIABLE);

Thank you!


#2

Use angular-local-storage. It’s awesome. I’m using it myself and it gracefully falls back to cookies.

And Cordova has a storage plugin as well.

bower install angular-local-storage --save


#3

LocalStorage is great, but you said “large data” - I don’t know how large, but you’re limited with LocalStorage to 5mb.

I’ve been using https://github.com/lite4cordova/Cordova-SQLitePlugin which is fantastic if a little higher-maintenance. It uses an API much like WebSQL but basically creates a SQLite database in the app’s Documents folder.


#4

Thanks for your suggestion, it sounds really cool! I’m gonna have a try.


#5

Was too fast with my reply; didn’t notice the ‘large data’ comment. Your SQLite suggestion looks awesome by the way.


#6

The size is around 100mb, not too “large”, maybe it’s not a good idea to store this data in client side. I’m gonna try the Cordova-SQLitePlugin, thanks!


#7

And how about using the File API? Infinite storage. Key is filename, value is contents of the file:-)
Have a look at https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md.
In the latest versions it is now possible to address files in a device independent way. A big improvement for cross platform dfevelopment. You can store files at cdvfile://localhost/persistent/path/to/file.
Other interesting plugin is https://github.com/apache/cordova-plugin-file-transfer/blob/master/doc/index.md to tranfer big files from remote to your device. Combine this with https://github.com/MobileChromeApps/zip so you can download zipped content, and unzip it somewhere in local persistent storage.


#8

has anyone tried angular-cache
http://jmdobry.github.io/angular-cache

looks interesting for caching http request or anything else and is back (and sync’d) with localstorage


#9

Angular-cache works really well. I used it for a while. Had some issues with controlling expiration. It’s all configurable though - it just didn’t jive with what I was doing. However, it works great for most cases. Very well designed.]

Also look at ng-storage : https://github.com/gsklee/ngStorage