* Define cachekey in cache.php.

This commit is contained in:
Lufei
2023-06-08 14:51:02 +08:00
parent dbdad3b5af
commit 6e6d20032e
4 changed files with 26 additions and 10 deletions
+15
View File
@@ -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';
+7 -6
View File
@@ -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');
+1 -1
View File
@@ -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);
+3 -3
View File
@@ -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())
{