WorkerStartEvent.php 547 B

123456789101112131415161718192021222324
  1. <?php
  2. namespace App\Events;
  3. use Cache;
  4. use DB;
  5. use Hhxsv5\LaravelS\Swoole\Events\WorkerStartInterface;
  6. use Swoole\Http\Server;
  7. class WorkerStartEvent implements WorkerStartInterface
  8. {
  9. public function __construct()
  10. {
  11. }
  12. public function handle(Server $server, $workerId)
  13. {
  14. if (isset($server->startMsecTime) && Cache::get("swooleServerStartMsecTime") != $server->startMsecTime) {
  15. Cache::forever("swooleServerStartMsecTime", $server->startMsecTime);
  16. DB::table('ws')->delete();
  17. }
  18. }
  19. }