作者 邓超

统计缓存

@@ -447,8 +447,8 @@ class MailListV2Es2 extends Base { @@ -447,8 +447,8 @@ class MailListV2Es2 extends Base {
447 $body['query']['bool']['must'][] = ['term'=>['folder_as_int'=>folder2int($folder)]]; 447 $body['query']['bool']['must'][] = ['term'=>['folder_as_int'=>folder2int($folder)]];
448 if($this->assignSql($folder)) $body['query']['bool']['must'][] = $this->assignSql($folder); 448 if($this->assignSql($folder)) $body['query']['bool']['must'][] = $this->assignSql($folder);
449 // logs('count :'.json_encode($body)); 449 // logs('count :'.json_encode($body));
450 - if($folder=='垃圾箱'){  
451 - $key = 'laji_count:'.md5(json_encode($body)); 450 + if(app()->request('nocache')!='web'){
  451 + $key = 'count:'.date('Ymd').md5(json_encode($body));
452 $a = redis()->get($key); 452 $a = redis()->get($key);
453 if(!is_numeric($a)){ 453 if(!is_numeric($a)){
454 $a = $this->es->count($body); 454 $a = $this->es->count($body);
@@ -472,6 +472,17 @@ class MailListV2Es2 extends Base { @@ -472,6 +472,17 @@ class MailListV2Es2 extends Base {
472 472
473 if($this->assignSql('收件箱')) 473 if($this->assignSql('收件箱'))
474 $body['query']['bool']['must'][] = $this->assignSql('收件箱'); 474 $body['query']['bool']['must'][] = $this->assignSql('收件箱');
  475 +
  476 + if(app()->request('nocache')!='web'){
  477 + $key = 'flagged_count:'.date('Ymd').md5(json_encode($body));
  478 + $a = redis()->get($key);
  479 + if(!is_numeric($a)){
  480 + $a = $this->es->count($body);
  481 + redis()->set($key,$a,strtotime(date('Y-m-d',strtotime("+1 day"))) - time());
  482 + }
  483 + return $a;
  484 + }
  485 +
475 return $this->es->count($body); 486 return $this->es->count($body);
476 } 487 }
477 488