Dingo API 的缓存路由之后,我使用了 XHProf 做了以下分析。
电脑:MacBook Pro (15-inch, 2017)
环境:PHP 7.2.5
以下是没有运行缓存路由文件
使用命令
php artisan api:cache
运行之后,反而多了很多的解析函数。
可能因为有很多的路由。重复调用了很多的方法。
最后定位到这个方法。
Illuminate\Routing\Route::parseAction
/**
* Parse the route action into a standard array.
*
* @param callable|array|null $action
* @return array
*
* @throws \UnexpectedValueException
*/
protected function parseAction($action)
{
return RouteAction::parse($this->uri, $action);
}
这个方法会把本地缓存文件解析后变成路由。那如果路由非常多,导致数组很大,会不会导致内存溢出?想问一下大佬们的建议?
推荐文章: