微信小程序緩存過期時間問題


 

 

setCache(){
    if(this.judgeTime()){ //判斷緩存是否過期,過期就重新添加一個
    wx.setStorageSync('oldTime',this.oldTime());
    }
}
judgeTime(){ //判斷緩存是否過期
      let nowTime = Date.now();
      let oldTime = wx.getStorageSync('oldTime');
      if(oldTime && nowTime < oldTime){
       return false;
      }
      return true;
    }
 oldTime(){ //返回以現在為准的3天后的時間
      return Date.now() + 259200000; //毫秒(72小時)
    }
    this.setCache();

 

 

原文地址:https://blog.csdn.net/frank_hehe/article/details/106471555?utm_medium=distribute.pc_relevant.none-task-blog-OPENSEARCH-2.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-OPENSEARCH-2.control。如有侵權聯系刪除


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM