| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2019/5/22
- * Time: 15:20
- */
- namespace app\logic;
- use app\pplus\Instance;
- use app\lib\GlobConfigs;
- use app\logic\Mypack;
- class TimeRsync
- {
- use Instance;
- public function DoTimePublic($serv, $worker_id, $redis)
- {
- $key = TIME_RSYNC_KEY;
- $val = intval($redis->get($key));
- //有其它进程正在操作,不用重复
- if (!empty($val)) { return; }
- $selfval = $worker_id + 1;
- $redis->SETEX($key, 55 , $selfval);
- $newvel = $redis->get($key);
- if ($selfval != intval($newvel)){ return; }
- $time = time();
- $data = json_encode(['cmd'=>'test','act'=>'timeRsync','data'=>['t'=>$time,'s'=>date('Y-m-d H:i:s',$time)]]);
- $serv->task(Mypack::getInstance()->makeData($data));
- return ;
- }
- }
|