Files
orico-official-website-old/app/common/behavior/ModuleCacheBehavior.php
2024-10-29 14:04:59 +08:00

54 lines
1.7 KiB
PHP
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\common\behavior;
use think\Config;
use think\Request;
use think\Hook;
use think\App;
use think\Log;
class ModuleCacheBehavior {
protected static $moduleName = '';
protected static $cachemoduleName;
/**
* 系统配置读取并缓存
*/
public function appBegin(&$param) {
switch ($param['type']) {
case 'redirect': // 重定向跳转
break;
case 'module': // 模块/控制器/操作
self::$moduleName = $param['module'][0];
break;
case 'controller': // 执行控制器操作
break;
case 'method': // 回调方法
break;
case 'function': // 闭包
break;
case 'response': // Response 实例
break;
default:
throw new \InvalidArgumentException('dispatch type not support');
}
self::$cachemoduleName = Config::get('html_cache_module', array());
if (!empty(self::$cachemoduleName) && in_array(self::$moduleName, self::$cachemoduleName)) {
// 监听 app_dispatch
Hook::listen('app_cache_begin', $param);
}
App::$debug && Log::record("[ 模块缓存 ]内容命中缓存处理HOOK");
}
public function viewFilter(&$param) {
if (!empty(self::$cachemoduleName) && in_array(self::$moduleName, self::$cachemoduleName)) {
// 监听 app_cache_end
Hook::listen('app_cache_end', $param);
}
App::$debug && Log::record("[ 模块缓存 ]视图内容缓存处理HOOK");
}
}