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)
Sysbench is an excellent benchmark tool that can ...
When making a website, I found that video files, s...
This case is based on CentOS 7 system Suitable fo...
The test environment is set up with a mariadb 5.7...
This article shares the specific code for JavaScr...
This article example shares the specific code of ...
It is no exaggeration to say that hyperlinks conne...
This article mainly introduces the Mysql backup m...
Table of contents 1. Isolation Level READ UNCOMMI...
Mixin method: The browser cannot compile: The old...
[Problem description] Our production environment ...
In enterprises, database high availability has al...
1. Upper and lower list tags: <dl>..</dl...
This article shares the specific code of js to ac...
Table of contents 1. Mysql data structure 2. The ...