diff --git a/src/Swoole/Handlers/OnWorkerStart.php b/src/Swoole/Handlers/OnWorkerStart.php index 64cef5e78..ea2d6c3ac 100644 --- a/src/Swoole/Handlers/OnWorkerStart.php +++ b/src/Swoole/Handlers/OnWorkerStart.php @@ -37,7 +37,7 @@ public function __invoke($server, int $workerId) $this->dispatchServerTickTaskEverySecond($server); $this->streamRequestsToConsole($server); - $this->clearCache(); + $this->clearOpcodeCache(); if ($this->shouldSetProcessName) { $isTaskWorker = $workerId >= $server->setting['worker_num']; @@ -112,18 +112,13 @@ protected function streamRequestsToConsole($server) } /** - * Clear the cache of APCu and Opcache. + * Clear the APCu and Opcache caches. * * @return void */ - protected function clearCache() + protected function clearOpcodeCache() { - static $functions = [ - 'apcu_clear_cache', - 'opcache_reset', - ]; - - foreach ($functions as $function) { + foreach (['apcu_clear_cache', 'opcache_reset'] as $function) { if (function_exists($function)) { $function(); }