Mini Program Data Cache Related Knowledge Data cache: caches data so that when the applet is opened again after exiting, the last saved data can be read from the cache. The commonly used data cache APIs are shown in the following table: Note : Stores the data at the specified key in the local cache. The original content corresponding to the key will be overwritten. The data will always be available unless the user actively deletes it or the system clears it due to storage space reasons. The maximum length of data stored in a single key is 1MB, and the upper limit for all data storage is 10MB. parameter For detailed parameters, please see Save data cache // Save data cache wx.setStorage({ key: 'key', // The key specified in the local cache data: 'value', // content to be stored (supports object or string) success: res => {}, // callback function for successful interface call fail: res => {} // callback function for interface call failure}) Get data cache // Get data cache wx.getStorage({ key: 'key', // The key specified in the local cache success: res => { // Callback function of successful interface call console.log(res.data) }, fail: res => {} // callback function for interface call failure}) Example: Storing and retrieving in onLoad // pages/test/test.js Page({ onLoad: function(options) { // Save data cache wx.setStorage({ key: 'key', // The key specified in the local cache data: 'value', // content to be stored (supports object or string) success: res => { // Get data cache wx.getStorage({ key: 'key', // The key specified in the local cache success: res => { // Callback function of successful interface call console.log(res.data) }, fail: res => { } // callback function for interface call failure}) }, // callback function for successful interface call fail: res => {} // callback function for failed interface call }) } }) This is the end of this article about the application and implementation of the mini-program data caching mechanism. For more relevant mini-program data caching content, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Windows 2019 Activation Tutorial (Office2019)
>>: Detailed explanation of the definition and usage of MySQL stored functions (custom functions)
Due to encoding reasons, garbled characters will ...
The common way to deploy a springboot project to ...
Table of contents 1. React combined with Antd to ...
This article mainly introduces the effect of div ...
Deleting a single table: DELETE FROM tableName WH...
1.service command The service command actually go...
The basic principle of all animations is to displ...
background The company code is provided to third ...
Two days ago, I took advantage of the Double 11 s...
This article introduces how to configure Nginx to...
I believe that many partners who have just come i...
Preface Since the most important data structure i...
Recently, due to the increase in buttons in the b...
Result: html <nav id="nav-1"> <...
Find information Some methods found on the Intern...