From cdc174acdcbeb965834944575e91bb932030ffb5 Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Wed, 14 Oct 2020 09:57:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0index=5Ftpl=5Ftype=3Dsimple?= =?UTF-8?q?=E6=97=B6=E9=87=8D=E5=BB=BA=E7=BC=93=E5=AD=98=E7=9A=84=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Tasks/MaintainTask.php | 36 +++++++++++++++++++++++++----- app/Console/Tasks/Task.php | 2 +- app/Console/Tasks/UpgradeTask.php | 6 ----- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/app/Console/Tasks/MaintainTask.php b/app/Console/Tasks/MaintainTask.php index f360db8f..9ac60365 100644 --- a/app/Console/Tasks/MaintainTask.php +++ b/app/Console/Tasks/MaintainTask.php @@ -4,6 +4,9 @@ namespace App\Console\Tasks; use App\Caches\IndexFreeCourseList as IndexFreeCourseListCache; use App\Caches\IndexNewCourseList as IndexNewCourseListCache; +use App\Caches\IndexSimpleFreeCourseList as IndexSimpleFreeCourseListCache; +use App\Caches\IndexSimpleNewCourseList as IndexSimpleNewCourseListCache; +use App\Caches\IndexSimpleVipCourseList as IndexSimpleVipCourseListCache; use App\Caches\IndexVipCourseList as IndexVipCourseListCache; use App\Http\Admin\Services\Setting as SettingService; use App\Library\Utils\Password as PasswordUtil; @@ -22,20 +25,41 @@ class MaintainTask extends Task { $section = $params[0] ?? null; + $site = $this->getSettings('site'); + + $type = $site['index_tpl_type'] ?: 'full'; + if (!$section || $section == 'new_course') { - $cache = new IndexNewCourseListCache(); - $cache->rebuild(); + if ($type == 'full') { + $cache = new IndexNewCourseListCache(); + $cache->rebuild(); + } else { + $cache = new IndexSimpleNewCourseListCache(); + $cache->rebuild(); + } } if (!$section || $section == 'free_course') { - $cache = new IndexFreeCourseListCache(); - $cache->rebuild(); + if ($type == 'full') { + $cache = new IndexFreeCourseListCache(); + $cache->rebuild(); + } else { + $cache = new IndexSimpleFreeCourseListCache(); + $cache->rebuild(); + } } if (!$section || $section == 'vip_course') { - $cache = new IndexVipCourseListCache(); - $cache->rebuild(); + if ($type == 'full') { + $cache = new IndexVipCourseListCache(); + $cache->rebuild(); + } else { + $cache = new IndexSimpleVipCourseListCache(); + $cache->rebuild(); + } } + + echo 'rebuild index course cache success' . PHP_EOL; } /** diff --git a/app/Console/Tasks/Task.php b/app/Console/Tasks/Task.php index 6478ed18..350cb5ec 100644 --- a/app/Console/Tasks/Task.php +++ b/app/Console/Tasks/Task.php @@ -41,7 +41,7 @@ class Task extends \Phalcon\Cli\Task { $appService = new AppService(); - return $appService->getLogger($section); + return $appService->getSettings($section); } } diff --git a/app/Console/Tasks/UpgradeTask.php b/app/Console/Tasks/UpgradeTask.php index 13bb53fb..8700703d 100644 --- a/app/Console/Tasks/UpgradeTask.php +++ b/app/Console/Tasks/UpgradeTask.php @@ -43,7 +43,6 @@ class UpgradeTask extends Task public function resetAnnotationAction() { $config = $this->getConfig(); - $redis = $this->getRedis(); $dbIndex = $config->path('annotation.db'); @@ -56,9 +55,7 @@ class UpgradeTask extends Task echo "start reset annotation..." . PHP_EOL; if (count($keys) > 0) { - $keys = $this->handlePhKeys($keys); - $redis->del(...$keys); $redis->del($statsKey); } @@ -74,7 +71,6 @@ class UpgradeTask extends Task public function resetMetadataAction() { $config = $this->getConfig(); - $redis = $this->getRedis(); $dbIndex = $config->path('metadata.db'); @@ -87,9 +83,7 @@ class UpgradeTask extends Task echo "start reset metadata..." . PHP_EOL; if (count($keys) > 0) { - $keys = $this->handlePhKeys($keys); - $redis->del(...$keys); $redis->del($statsKey); }