作者 邓超

x

@@ -41,7 +41,10 @@ trait RedisQuery { @@ -41,7 +41,10 @@ trait RedisQuery {
41 public function get($key, $default=null) 41 public function get($key, $default=null)
42 { 42 {
43 $data = $this->getClient()->get($key); 43 $data = $this->getClient()->get($key);
44 - if($data === null){ 44 + if($data === false){
  45 + if($default instanceof \Closure){
  46 + return $default();
  47 + }
45 return $default; 48 return $default;
46 } 49 }
47 return $this->unserialize($data); 50 return $this->unserialize($data);
@@ -286,7 +286,16 @@ class SyncMail { @@ -286,7 +286,16 @@ class SyncMail {
286 $p++; 286 $p++;
287 287
288 foreach ($uids as $k=>$uid){ 288 foreach ($uids as $k=>$uid){
289 - if($this->db->cache(86400*30,false)->value(listsSql::first(dbWhere(['email_id'=>$this->emailId(),'folder_id'=>$folder_id,'uid'=>$uid]),'count(*) as c'))){ 289 +
  290 + $has = redis()->get('h_'.$folder_id.'_'.$uid,function () use ($folder_id,$uid){
  291 + $num = $this->db->value(listsSql::first(dbWhere(['email_id'=>$this->emailId(),'folder_id'=>$folder_id,'uid'=>$uid]),'count(*) as c'));
  292 + if($num){
  293 + redis()->set('h_'.$folder_id.'_'.$uid,1,86400);
  294 + }
  295 + return $num;
  296 + });
  297 +
  298 + if($has){
290 unset($uids[$k]); 299 unset($uids[$k]);
291 } 300 }
292 } 301 }