add:新增服务缓存,提高性能
This commit is contained in:
parent
42e6cd36aa
commit
5979088144
@ -53,4 +53,28 @@ class Module extends CatchController
|
|||||||
|
|
||||||
return CatchResponse::success();
|
return CatchResponse::success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存
|
||||||
|
*
|
||||||
|
* @time 2020年09月21日
|
||||||
|
* @return Json
|
||||||
|
*/
|
||||||
|
public function cache()
|
||||||
|
{
|
||||||
|
return CatchResponse::success(CatchAdmin::cacheServices());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清理缓存
|
||||||
|
*
|
||||||
|
* @time 2020年09月21日
|
||||||
|
* @return Json
|
||||||
|
*/
|
||||||
|
public function clear()
|
||||||
|
{
|
||||||
|
return !file_exists(CatchAdmin::getCacheServicesFile()) ?
|
||||||
|
CatchResponse::fail('模块没有缓存') :
|
||||||
|
CatchResponse::success(unlink(CatchAdmin::getCacheServicesFile()));
|
||||||
|
}
|
||||||
}
|
}
|
@ -40,6 +40,9 @@ $router->group(function () use ($router) {
|
|||||||
// 模块管理
|
// 模块管理
|
||||||
$router->get('modules', '\catchAdmin\system\controller\Module@index');
|
$router->get('modules', '\catchAdmin\system\controller\Module@index');
|
||||||
$router->put('modules/<module>', '\catchAdmin\system\controller\Module@disOrEnable');
|
$router->put('modules/<module>', '\catchAdmin\system\controller\Module@disOrEnable');
|
||||||
|
$router->put('cache/modules', '\catchAdmin\system\controller\Module@cache');
|
||||||
|
$router->delete('clear/modules', '\catchAdmin\system\controller\Module@clear');
|
||||||
|
|
||||||
})->middleware('auth');
|
})->middleware('auth');
|
||||||
|
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ class CatchAdmin
|
|||||||
public static function cacheServices()
|
public static function cacheServices()
|
||||||
{
|
{
|
||||||
return file_put_contents(self::getCacheServicesFile(), "<?php\r\n return "
|
return file_put_contents(self::getCacheServicesFile(), "<?php\r\n return "
|
||||||
. var_export(self::getModuleServices(), true) . ';');
|
. var_export(self::getEnabledService(), true) . ';');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -425,7 +425,7 @@ class CatchAdmin
|
|||||||
* @time 2019年11月30日
|
* @time 2019年11月30日
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
protected static function getCacheServicesFile()
|
public static function getCacheServicesFile()
|
||||||
{
|
{
|
||||||
return self::cacheDirectory() . 'services.php';
|
return self::cacheDirectory() . 'services.php';
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,9 @@ class CatchAdminService extends Service
|
|||||||
*/
|
*/
|
||||||
protected function registerServices()
|
protected function registerServices()
|
||||||
{
|
{
|
||||||
$services = CatchAdmin::getEnabledService();
|
$services = file_exists(CatchAdmin::getCacheServicesFile()) ?
|
||||||
|
include CatchAdmin::getCacheServicesFile() :
|
||||||
|
CatchAdmin::getEnabledService();
|
||||||
|
|
||||||
foreach ($services as $service) {
|
foreach ($services as $service) {
|
||||||
if (class_exists($service)) {
|
if (class_exists($service)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user