mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
增加请求缓存功能 路由支持设置请求缓存
This commit is contained in:
@@ -119,6 +119,8 @@ class Request
|
||||
protected $bind = [];
|
||||
// php://input
|
||||
protected $input;
|
||||
// 请求缓存
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
@@ -1453,6 +1455,30 @@ class Request
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取缓存
|
||||
* @access public
|
||||
* @param string $key 缓存标识
|
||||
* @param mixed $expire 静态有效期
|
||||
* @return mixed
|
||||
*/
|
||||
public function cache($key, $expire = null)
|
||||
{
|
||||
if (Cache::has($key)) {
|
||||
// 读取缓存
|
||||
$content = Cache::get($key);
|
||||
$response = Response::create($content)->header('Content-Type', Cache::get($key . '_header'));
|
||||
throw new \think\exception\HttpResponseException($response);
|
||||
} else {
|
||||
$this->cache = [$key, $expire];
|
||||
}
|
||||
}
|
||||
|
||||
public function getCache()
|
||||
{
|
||||
return $this->cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前请求绑定的对象实例
|
||||
* @access public
|
||||
|
||||
Reference in New Issue
Block a user