This.expire = new Date().getTime() {// expire = new Date().gettime () + expire * 1000; } // set set(key, value) {let data = {expire: this.expire, value}; // Set cache wx.setStorageSync(key, data); } // forever(key, value) {let expire = new Date().gettime () + 9999999999 * 1000; let data = { expire, value }; // Set cache wx.setStorageSync(key, data); } let time = new Date().gettime (); Let data = wx.getStoragesync (key); if (data ! Wx.removestoragesync (key); {if (time > data.expire) {wx.removeStoragesync (key); return false; } return true; } return false; } // Get (key) {if (this.has(key)) {return wx.getStoragesync (key).value; } return null; } // Delete del(key) {wx.removeStoragesync (key); } } export {Cache}Copy the code