作者 邓超

优化同步

@@ -84,9 +84,8 @@ function start(){ @@ -84,9 +84,8 @@ function start(){
84 $sync->noSyncFolder(); 84 $sync->noSyncFolder();
85 } 85 }
86 86
87 - $sync->endSyncTime = time();  
88 87
89 - $sync->isUidAfter(2)->sync(); 88 + $sync->setEndSyncTime()->isUidAfter(2)->sync();
90 89
91 $sync = null; 90 $sync = null;
92 unset($sync); 91 unset($sync);
@@ -42,9 +42,9 @@ $pm->addBatch(3,function (\Swoole\Process\Pool $pool, int $worker_id){ @@ -42,9 +42,9 @@ $pm->addBatch(3,function (\Swoole\Process\Pool $pool, int $worker_id){
42 try{ 42 try{
43 // 开始同步 43 // 开始同步
44 if(redis()->add('sync_my_day:'.date('d').'_'.$id,$id,86400)){ 44 if(redis()->add('sync_my_day:'.date('d').'_'.$id,$id,86400)){
45 - (new \Service\SyncMail($id))->setIsBody(false)->sync(); 45 + (new \Service\SyncMail($id))->setIsBody(false)->setEndSyncTime()->sync();
46 }else{ 46 }else{
47 - (new \Service\SyncMail($id))->setIsBody(false)->isUidAfter(2)->sync(); 47 + (new \Service\SyncMail($id))->setIsBody(false)->setEndSyncTime()->isUidAfter(2)->sync();
48 } 48 }
49 49
50 }catch (Throwable $e){ 50 }catch (Throwable $e){
@@ -302,7 +302,7 @@ class SyncMail { @@ -302,7 +302,7 @@ class SyncMail {
302 public $endSyncTime = 0; 302 public $endSyncTime = 0;
303 303
304 public function setEndSyncTime($time=0){ 304 public function setEndSyncTime($time=0){
305 - $this->endSyncTime = $time?$time:time(); 305 + $this->endSyncTime = $time ? $time : time();
306 return $this; 306 return $this;
307 } 307 }
308 308