From 6e6d20032e976cd277d2b488faf8a805ca9b79a9 Mon Sep 17 00:00:00 2001 From: Lufei Date: Thu, 8 Jun 2023 14:51:02 +0800 Subject: [PATCH] * Define cachekey in cache.php. --- config/cache.php | 15 +++++++++++++++ module/block/control.php | 13 +++++++------ module/bug/control.php | 2 +- module/execution/control.php | 6 +++--- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/config/cache.php b/config/cache.php index f92f0ad20a..d7a147eea9 100644 --- a/config/cache.php +++ b/config/cache.php @@ -16,3 +16,18 @@ $config->cache->fullPages[] = 'product|all'; $config->cache->fullPages[] = 'project|browse'; $config->cache->fullPages[] = 'block|printblock'; $config->cache->fullPages[] = 'screen|view'; + +$config->cacheKeys = new stdclass(); + +$config->cacheKeys->block = new stdclass(); +$config->cacheKeys->block->welcome = 'welcome'; +$config->cacheKeys->block->contribute = 'contribute'; +$config->cacheKeys->block->projectStatistic = 'projectStatistic%s%s%s'; +$config->cacheKeys->block->recentProject = 'recentProject'; + +$config->cacheKeys->execution = new stdclass(); +$config->cacheKeys->execution->ajaxGetDropMenuProjects = 'ajaxDropMenuProjects'; +$config->cacheKeys->execution->ajaxGetDropMenuExecutions = 'ajaxDropMenuExecutions'; + +$config->cacheKeys->bug = new stdclass(); +$config->cacheKeys->bug->browse = 'bugBrowse%s'; diff --git a/module/block/control.php b/module/block/control.php index 46d2d24136..2a819f5910 100755 --- a/module/block/control.php +++ b/module/block/control.php @@ -380,7 +380,7 @@ class block extends control { $this->view->tutorialed = $this->loadModel('tutorial')->getTutorialed(); - $cacheKey = 'welcomeBlockData'; + $cacheKey = $this->config->cacheKeys->block->welcome; if(helper::isCacheEnabled() && $this->cache->has($cacheKey)) { $data = $this->cache->get($cacheKey); @@ -418,14 +418,15 @@ class block extends control */ public function contribute() { - if(helper::isCacheEnabled() && $this->cache->has('contributeBlockData')) + $cacheKey = $this->config->cacheKeys->block->contribute; + if(helper::isCacheEnabled() && $this->cache->has($cacheKey)) { - $data = $this->cache->get('contributeBlockData'); + $data = $this->cache->get($cacheKey); } else { $data = $this->loadModel('user')->getPersonalData(); - if($this->config->cache->enable) $this->cache->set('contributeBlockData', $data); + if($this->config->cache->enable) $this->cache->set($cacheKey, $data); } $this->view->data = $data; $this->display(); @@ -983,7 +984,7 @@ class block extends control return false; } - $cacheKey = __FUNCTION__ . $status . $count . $excludedModel; + $cacheKey = sprintf($this->config->cacheKeys->block->projectStatistic, $status, $count, $excludedModel); if(helper::isCacheEnabled() && $this->cache->has($cacheKey)) { $projects = $this->cache->get($cacheKey); @@ -2036,7 +2037,7 @@ class block extends control /* load pager. */ $this->app->loadClass('pager', $static = true); $pager = new pager(0, 3, 1); - $cacheKey = __FUNCTION__; + $cacheKey = $this->config->cacheKeys->block->recentProject; if(helper::isCacheEnabled() && $this->cache->has($cacheKey)) { $this->app->loadLang('project'); diff --git a/module/bug/control.php b/module/bug/control.php index bd318c6270..4b1cc363ba 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -165,7 +165,7 @@ class bug extends control $pager = new pager($recTotal, $recPerPage, $pageID); /* Get executions. */ - $cacheKey = "bugBrowse{$this->projectID}"; + $cacheKey = sprintf($this->config->cacheKeys->bug->browse, $this->projectID); if(helper::isCacheEnabled() && $this->cache->has($cacheKey)) { $executions = $this->cache->get($cacheKey); diff --git a/module/execution/control.php b/module/execution/control.php index aefc876ced..8cec15cec8 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -3193,7 +3193,7 @@ class execution extends control * Manage products. * * @param int $executionID - * @param from $from + * @param string $from * @access public * @return void */ @@ -3831,8 +3831,8 @@ class execution extends control $this->view->executionID = $executionID; $this->view->extra = $extra; - $cacheProjectsKey = 'execution|dropmenu|project'; - $cacheExecutionsKey = 'execution|dropmenu|executions'; + $cacheProjectsKey = $this->config->cacheKeys->execution->ajaxGetDropMenuProjects; + $cacheExecutionsKey = $this->config->cacheKeys->execution->ajaxGetDropMenuExecutions; if(helper::isCacheEnabled()) {