When does Mini Program use setStorage and when does setStorageSync? use?

when does Mini Program use setStorage and when does setStorageSync? use?

Mar.05,2021

Synchronize asynchronism. Synchronize means that your next operation must be completed in the previous step before it can be executed. Async means that the following code has nothing to do with this operation. How to choose your code logic, whether the following operations need memory must be saved, because the operation of memory is time-consuming, often not as fast as the code.


the former is an asynchronous operation, and the latter is a Synchronize operation. If the subsequent operation depends on changing the data after storage, Synchronize is required, otherwise the subsequent operation will still use unupdated data. If the subsequent operations do not need to use the changed storage data, then do not need to immediately Synchronize, then use asynchronous operation to save memory.

Menu