mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 15:02:47 +08:00
Merge branch 'master' into bugfix3
This commit is contained in:
@@ -1502,9 +1502,10 @@ class Request
|
||||
* @access public
|
||||
* @param string $key 缓存标识,支持变量规则 ,例如 item/:name/:id
|
||||
* @param mixed $expire 缓存有效期
|
||||
* @param array $except 缓存排除
|
||||
* @return void
|
||||
*/
|
||||
public function cache($key, $expire = null)
|
||||
public function cache($key, $expire = null, $except = [])
|
||||
{
|
||||
if (false !== $key && $this->isGet() && !$this->isCheckCache) {
|
||||
// 标记请求缓存检查
|
||||
@@ -1516,14 +1517,19 @@ class Request
|
||||
if ($key instanceof \Closure) {
|
||||
$key = call_user_func_array($key, [$this]);
|
||||
} elseif (true === $key) {
|
||||
foreach ($except as $rule) {
|
||||
if (0 === strpos($this->url(), $rule)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 自动缓存功能
|
||||
$key = '__URL__';
|
||||
$key = md5($this->host()) . '__URL__';
|
||||
} elseif (strpos($key, '|')) {
|
||||
list($key, $fun) = explode('|', $key);
|
||||
}
|
||||
// 特殊规则替换
|
||||
if (false !== strpos($key, '__')) {
|
||||
$key = str_replace(['__MODULE__', '__CONTROLLER__', '__ACTION__', '__URL__'], [$this->module, $this->controller, $this->action, md5($this->url())], $key);
|
||||
$key = str_replace(['__MODULE__', '__CONTROLLER__', '__ACTION__', '__URL__', ''], [$this->module, $this->controller, $this->action, md5($this->url())], $key);
|
||||
}
|
||||
|
||||
if (false !== strpos($key, ':')) {
|
||||
|
||||
Reference in New Issue
Block a user