Storage is persistent rather than permanent

The data store life cycle is the same as that of the small program itself, that is, the data is always available unless the user actively deletes it or the data is automatically cleared after a certain period of time. The maximum length of data stored by a key is 1MB, and the maximum length of all data stores is 10MB. For example, when a user deletes a small program from wechat, the data stored in the storage will be deleted.

Storage is isolated by user dimension.

User A cannot read user B’s data on the same device. For example, user A and user B store data named name on the same device to record the user’s name.

// getUserName is used to simulate getting the name of the user. We assume that user A's name is A and user B's name is B.let userName = getUserName();
wx.setStorageSync('name', userName);
console.log(name);
Copy the code

So when user A accesses the applet, the result is ‘A’, and when user B accesses the applet, the result is’ B ‘. The storage space between users is independent of each other. This point can be easily used to statistics small program UV.

After a user changes devices, data in the storage is lost

After a storage device is replaced, local data is naturally lost. Therefore, do not rely on the local storage for key information.