Data storage method and device
The present disclosure provides a data storage method and device, wherein the method comprises: invoking a local storage interface of a browser, and storing application data to a storage space under a domain name corresponding to a current page, the domain name supporting a generic domain name; when the storage space under the domain name is insufficient to store the application data, creating at least one iframe, each iframe loading a proxy page corresponding to a sub-domain name under the domain name; and storing remaining application data in an additional storage space corresponding to the at least one sub-domain name. The method allows the local storage of a browser to meet the data storage demand of various capacities.
1. A data storage method, comprising:
invoking a storage interface of a browser, and storing application data associated with displaying a page by the browser to a storage space under a domain name corresponding to the page, the domain name including a first root domain name;
when the storage space under the domain name is insufficient to store the application data, creating at least one HTML frame (iframe) under a generic domain name that includes a second root domain name different from the first root domain name, each iframe loading one proxy page, each proxy page corresponding to one sub-domain name under the generic domain name, by:
creating a first iframe, the first iframe loading a first proxy page, the first proxy page corresponding to a first sub-domain name under the generic domain name; and
in response to determining that a first additional storage space corresponding to the first sub-domain name is still insufficient to store the remaining application data, creating a second iframe, the second iframe loading a second proxy page corresponding to a second sub-domain name under the generic domain name; and
storing remaining application data in an additional storage space corresponding to the one sub-domain name.
2. The method according to claim 1 , wherein a size of the application data changes during displaying the page, and creating at least one HTML frame (iframe) comprises creating a number of iframes corresponding to a change of the size of the application data.
3. The method according to claim 1 , wherein the creating at least one HTML frame (iframe), each iframe loading one proxy page, each proxy page corresponding to one sub-domain name under the generic domain name comprises:
calculating a number of iframes to be created according to a size of the application data; and
creating the number of iframes, and loading one proxy page to each of the created iframes, each proxy page corresponding to one sub-domain name under the generic domain name.
4. The method according to claim 3 , wherein the size of the application data changes during displaying the page, and the number of iframes are created corresponding to a change of the size of the application data.
5. The method according to claim 1 , further comprising:
acquiring the application data from the storage space under the domain name and the additional storage space corresponding to the one sub-domain name when the stored application data is to be loaded into the browser.
6. The method according to claim 1 , wherein the storage space has a size same as that of the additional storage space.
7. One or more non-transitory computer-readable storage media, storing instructions executable by one or more processors to cause the one or more processors to perform operations comprising:
invoking a storage interface of a browser, and storing application data associated with displaying a page by the browser to a storage space under a domain name corresponding to the page, the domain name including a first root domain name;
when the storage space under the domain name is insufficient to store the application data, creating at least one HTML frame (iframe) under a generic domain name having a second root domain name different from the first root domain name, each iframe loading one proxy page, each proxy page corresponding to one sub-domain name under the generic domain name, by:
creating a first iframe, the first iframe loading a first proxy page, the first proxy page corresponding to a first sub-domain name under the generic domain name; and
in response to determining that a first additional storage space corresponding to the first sub-domain name is still insufficient to store the remaining application data, creating a second iframe, the second iframe loading a second proxy page corresponding to a second sub-domain name under the generic domain name; and
storing remaining application data in an additional storage space corresponding to the one sub-domain name.
8. The storage media according to claim 7 , wherein a size of the application data changes during displaying the page, and creating at least one HTML frame (iframe) comprises creating a number of iframes corresponding to a change of the size of the application data.
9. The storage media according to claim 7 , wherein the creating at least one HTML frame (iframe), each iframe loading one proxy page, each proxy page corresponding to one sub-domain name under the generic domain name comprises:
calculating a number of iframes to be created according to a size of the application data; and
creating the number of iframes, and loading one proxy page to each of the created iframes, each proxy page corresponding to one sub-domain name under the generic domain name.
10. The storage media according to claim 9 , wherein the size of the application data changes during displaying the page, and the number of iframes are created corresponding to a change of the size of the application data.
11. The storage media according to claim 7 , the operations further comprise:
acquiring the application data from the storage space under the domain name and the additional storage space corresponding to the one sub-domain name when the stored application data is to be loaded into the browser.
12. The storage media according to claim 7 , wherein the storage space has a size same as that of the additional storage space.
13. A data storage system, comprising a processor and a non-transitory computer-readable storage medium coupled to the processor and having instructions stored thereon, the instructions being executable by the processor to cause the processor to perform operations comprising:
invoking a storage interface of a browser, and storing application data associated with displaying a page by the browser to a storage space under a domain name corresponding to the page, the domain name including a first root domain name;
when the storage space under the domain name is insufficient to store the application data, creating at least one HTML frame (iframe) under a generic domain name having a second root domain name different from the first root domain name, each iframe loading one proxy page, each proxy page corresponding to one sub-domain name under the generic domain name, by:
creating a first iframe, the first iframe loading a first proxy page, the first proxy page corresponding to a first sub-domain name under the generic domain name; and
in response to determining that a first additional storage space corresponding to the first sub-domain name is still insufficient to store the remaining application data, creating a second iframe, the second iframe loading a second proxy page corresponding to a second sub-domain name under the generic domain name; and
storing remaining application data in an additional storage space corresponding to the one sub-domain name.
14. The system according to claim 13 , wherein a size of the application data changes during displaying the page, and creating at least one HTML frame (iframe) comprises creating a number of iframes corresponding to a change of the size of the application data.
15. The system according to claim 13 , wherein the creating at least one HTML frame (iframe), each iframe loading one proxy page, each proxy page corresponding to one sub-domain name under the generic domain name comprises:
calculating a number of iframes to be created according to a size of the application data; and
creating the number of iframes, and loading one proxy page to each of the created iframes, each proxy page corresponding to one sub-domain name under the generic domain name.
16. The system according to claim 13 , wherein the operations further comprise:
acquiring the application data from the storage space under the domain name and the additional storage space corresponding to the one sub-domain name when the stored application data is to be loaded into the browser.
17. The system according to claim 15 , wherein the size of the application data changes during displaying the page, and the number of iframes are created corresponding to a change of the size of the application data.