fix :
1、 redis select database feature: 1、 config tml data cache driver
This commit is contained in:
@@ -50,6 +50,7 @@ STORAGE_LOCAL_DIR = /mnt/gluster
|
||||
VIEW_DISPLAY_CACHE = false
|
||||
VIEW_TPL_CACHE = false
|
||||
VIEW_DATA_CACHE = false
|
||||
VIEW_DATA_CACHE_DRIVER = redis
|
||||
|
||||
# PROXY
|
||||
PROXY_STATUS = true
|
||||
|
||||
@@ -91,42 +91,7 @@ abstract class MongoModel
|
||||
return $this->getCol()->find($arrFilter, $arrOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $strKey
|
||||
* @return array|object|NULL
|
||||
*/
|
||||
public function checkCacheByKey(string $strKey): array|object|NULL
|
||||
{
|
||||
|
||||
if (config('view.view_data_cache') == false) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!empty($strKey)) {
|
||||
$arrResult = Cache::get($strKey);
|
||||
if (!empty($arrResult)) {
|
||||
return $arrResult;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $strKey
|
||||
* @param mixed $mixedData
|
||||
* @param integer $intLifeTime
|
||||
* @return void
|
||||
*/
|
||||
public function setCacheByKey(string $strKey, mixed $mixedData, int $intLifeTime)
|
||||
{
|
||||
if (!empty($strKey) && !empty($mixedData)) {
|
||||
Cache::set($strKey, $mixedData, $intLifeTime);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
@@ -176,4 +141,45 @@ abstract class MongoModel
|
||||
$Result = $this->getCol()->deleteMany($arrFilter, $arrOptions);
|
||||
return $Result->getDeletedCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $strKey
|
||||
* @return array|object|NULL
|
||||
*/
|
||||
public function checkCacheByKey(string $strKey): array|object|NULL
|
||||
{
|
||||
|
||||
if (config('view.view_data_cache') == false) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!empty($strKey)) {
|
||||
$arrResult = Cache::store(config('view.view_data_cache_driver'))->get($strKey);
|
||||
if (!empty($arrResult)) {
|
||||
return $arrResult;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $strKey
|
||||
* @param mixed $mixedData
|
||||
* @param integer $intLifeTime
|
||||
* @return void
|
||||
*/
|
||||
public function setCacheByKey(string $strKey, mixed $mixedData, int $intLifeTime)
|
||||
{
|
||||
if (config('view.view_data_cache') == false) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!empty($strKey) && !empty($mixedData)) {
|
||||
Cache::store(config('view.view_data_cache_driver'))->set($strKey, $mixedData, $intLifeTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ return [
|
||||
// 默认缓存驱动
|
||||
'default' => env('CACHE_DRIVER', 'file'),
|
||||
|
||||
'cache_time' => env('CACHE_TIME', 60 * 60 * 3), // 缓存时间 3小时
|
||||
// 缓存时间 3小时
|
||||
'cache_time' => env('CACHE_TIME', 60 * 60 * 3),
|
||||
|
||||
// 缓存连接方式配置
|
||||
'stores' => [
|
||||
@@ -36,12 +37,12 @@ return [
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
// 端口
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
// 密码
|
||||
// 密码
|
||||
'password' => env('REDIS_PASSWORD', ''),
|
||||
// 缓存前缀
|
||||
'prefix' => env('REDIS_PREFIX', ''),
|
||||
// 缓存前缀
|
||||
'database' => env('REDIS_DATABASE', 0),
|
||||
// 库
|
||||
'select' => env('REDIS_DATABASE', 0),
|
||||
|
||||
// 缓存标签前缀
|
||||
'tag_prefix' => '',
|
||||
|
||||
@@ -35,6 +35,9 @@ return [
|
||||
// 是否开启模板编译缓存,设为false则每次都会重新编译
|
||||
'tpl_cache' => env('VIEW_TPL_CACHE', false),
|
||||
|
||||
//页面数据缓存,实际是控制器数据缓存
|
||||
//页面数据缓存
|
||||
'view_data_cache' => env('VIEW_DATA_CACHE', false),
|
||||
|
||||
//页面数据缓存驱动
|
||||
'view_data_cache_driver' => env('VIEW_DATA_CACHE_DRIVER', false),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user