+ [perf] Add cache handler.

This commit is contained in:
朱金勇
2024-11-20 15:42:49 +08:00
parent 3ad3f2dc48
commit a3c1dcaacf
5 changed files with 71 additions and 11 deletions
+2 -3
View File
@@ -104,13 +104,12 @@ class baseCache
* 构造方法。
* The construct method.
*
* @param object $app
* @access public
* @return void
*/
public function __construct($app)
public function __construct()
{
global $config;
global $config, $app;
$this->app = $app;
$this->config = $config;
View File
+34
View File
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
/**
* The setting cache handler file.
*
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
* @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
* @package action
* @version $Id$
* @link https://www.zentao.net
*/
class settingHandler
{
/**
* 获取系统及用户的配置信息。
* Get system and personal config.
*
* @param string $account
* @access public
* @return array
*/
public function getSysAndPersonalConfig(string $account)
{
$owner = 'system,' . ($account ? $account : '');
$records = $this->cache->select('*')->from(TABLE_CONFIG)
->where('owner')->in($owner)
->beginIF(!$this->app->upgrading)->andWhere('vision')->in(array('', $this->config->vision))->fi()
->orderBy('id')
->fetchAll('id');
return $records;
}
}
+34 -2
View File
@@ -10,8 +10,40 @@ declare(strict_types=1);
* @version $Id: model.php 5114 2013-07-12 06:02:59Z chencongzhi520@gmail.com $
* @link https://www.zentao.net
*/
?>
<?php
class cacheModel extends model
{
/**
* 构造方法。
* Constructor.
*
* @access public
* @return void
*/
public function __construct()
{
parent::__construct();
$this->cache = $this->app->loadClass('cache');
}
/**
* 魔术方法,加载子类。
* Magic get method.
*
* @param string $handlerName
* @access public
* @return object
*/
public function __get(string $handlerName)
{
include dirname(__FILE__) . DS . 'handler' . DS . strtolower($handlerName) . '.php';
$handlerName = $handlerName . 'Handler';
$handler = new $handlerName();
$handler->cache = $this->cache;
$handler->app = $this->app;
$handler->config = $this->config;
return $handler;
}
}
+1 -6
View File
@@ -244,12 +244,7 @@ class settingModel extends model
*/
public function getSysAndPersonalConfig(string $account = ''): array
{
$owner = 'system,' . ($account ? $account : '');
$records = $this->dao->select('*')->from(TABLE_CONFIG)
->where('owner')->in($owner)
->beginIF(!$this->app->upgrading)->andWhere('vision')->in(array('', $this->config->vision))->fi()
->orderBy('id')
->fetchAll('id');
$records = $this->cache->setting->getSysAndPersonalConfig($account);
if(!$records) return array();
$vision = $this->config->vision;