Localstorage, Localforage, the comparison of web SQL three

Source: Internet
Author: User

The most recent project used the front-end storage, originally selected Localstorage, this is the HTML5 inside the new API, the usage is very simple. SetItem GetItem Clear. It is important to note that the data stored in the Localstorage in the form of a string, the time taken out is also in the form of a string to get. because the general data in the project is stored in JSON or array mode. Json.parse and json.stringify are therefore required prior to access.

Another inconvenience in localstroage is that it is simply a data store with no self-increment ID. This does not say, when fetching data, can only traverse the search, for example, you want to find a time period of data, here is only a traversal query. The amount of data is not what, the amount of data is really troublesome, after all, it is easy to traverse, who can bear.

There are similarities between Web SQL and common MySQL. The language of the operation is also an SQL statement. Support Some SQL common find Ah, add AH update what. I think it's still better, and the mobile side should have no problem. But there seems to be some problems with browser compatibility on the PC. Because our project soon found an alternative to the Localforage Web SQL has not yet been thoroughly researched.

Localforage is developed by Mozilla, the advantages: 1. Same as Localstorage but when you access data, you can save data in arrays, JSON, and other formats, without having to change the data format any further. In addition, the Localstroage access data is synchronous, while the localforage is asynchronous and supports promise mode. This cannot be said to be superior or inferior, and synchronization has the advantage of synchronization.

Localforage also does not support SQL queries, like Localstorage, can only do simple data access, so to see, the larger front-end data storage, or Web SQL will be more useful. It's a little confusing to write that Localforage is based on localstroage Web SQL and how does IT support SQL queries?

Localstorage, Localforage, the comparison of web SQL three

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.