Преглед на файлове

中间计量,缓存,兼容旧数据

MaiXinRong преди 5 години
родител
ревизия
b7de36976d
променени са 2 файла, в които са добавени 9 реда и са изтрити 3 реда
  1. 7 3
      app/service/report_memory.js
  2. 2 0
      app/service/stage.js

+ 7 - 3
app/service/report_memory.js

@@ -87,7 +87,11 @@ module.exports = app => {
                 }
 
                 this.ctx.stage = stage;
-                this.ctx.stage.cacheTime = this.ctx.stage.readOnly ? (this.ctx.stage.cache_time_r).getTime(): (this.ctx.stage.cache_time_l).getTime();
+                let time = this.ctx.stage.readOnly ? this.ctx.stage.cache_time_r : this.ctx.stage.cache_time_l;
+                if (!time) {
+                    time = this.ctx.stage.in_time ? this.ctx.stage.in_time : new Date();
+                }
+                this.ctx.stage.cacheTime = time.getTime();//this.ctx.stage.readOnly ? (this.ctx.stage.cache_time_r).getTime(): (this.ctx.stage.cache_time_l).getTime();
             }
         }
 
@@ -186,11 +190,11 @@ module.exports = app => {
             await this._checkStage(sid);
             const cache = await this._getReportMemoryCache('mem_stage_im_tz', tid, sid, this.ctx.stage.cacheTime);
             if (cache) {
-                //console.log('cache');
+                console.log('cache');
                 return cache;
             }
 
-            //console.log('build');
+            console.log('build');
             if (!this.stageImData) {
                 this.stageImData = {};
                 try {

+ 2 - 0
app/service/stage.js

@@ -179,6 +179,8 @@ module.exports = app => {
                 user_id: this.ctx.session.sessionUser.accountId,
                 check_calc: false,
             };
+            newStage.cache_time_l = newStage.in_time;
+            newStage.cache_time_r = newStage.in_time;
             if (preStage) {
                 newStage.im_type = preStage.im_type;
                 newStage.im_pre = preStage.im_pre;