mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 23:02:48 +08:00
request类请求缓存cache方法标识支持变量规则
This commit is contained in:
@@ -1456,15 +1456,23 @@ class Request
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 读取缓存
|
* 读取或者设置缓存
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $key 缓存标识
|
* @param string $key 缓存标识,支持变量规则 ,例如 item/:name/:id
|
||||||
* @param mixed $expire 静态有效期
|
* @param mixed $expire 缓存有效期
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function cache($key, $expire = null)
|
public function cache($key, $expire = null)
|
||||||
{
|
{
|
||||||
if (Cache::has($key)) {
|
if (Cache::has($key)) {
|
||||||
|
if (false !== strpos($key, ':')) {
|
||||||
|
$param = $this->param();
|
||||||
|
foreach ($param as $item => $val) {
|
||||||
|
if (is_string($val) && false !== strpos($key, ':' . $item)) {
|
||||||
|
$key = str_replace(':' . $item, $val, $key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// 读取缓存
|
// 读取缓存
|
||||||
$content = Cache::get($key);
|
$content = Cache::get($key);
|
||||||
$response = Response::create($content)->header('Content-Type', Cache::get($key . '_header'));
|
$response = Response::create($content)->header('Content-Type', Cache::get($key . '_header'));
|
||||||
@@ -1474,6 +1482,11 @@ class Request
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取缓存设置
|
||||||
|
* @access public
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getCache()
|
public function getCache()
|
||||||
{
|
{
|
||||||
return $this->cache;
|
return $this->cache;
|
||||||
|
|||||||
Reference in New Issue
Block a user