mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
Query类增加cacheData方法用于数据缓存统一写入
This commit is contained in:
@@ -419,11 +419,7 @@ class Query
|
|||||||
}
|
}
|
||||||
if (isset($cache)) {
|
if (isset($cache)) {
|
||||||
// 缓存数据
|
// 缓存数据
|
||||||
if (isset($cache['tag'])) {
|
$this->cacheData($key, $result, $cache);
|
||||||
Cache::tag($cache['tag'])->set($key, $result, $cache['expire']);
|
|
||||||
} else {
|
|
||||||
Cache::set($key, $result, $cache['expire']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 清空查询条件
|
// 清空查询条件
|
||||||
@@ -491,11 +487,7 @@ class Query
|
|||||||
}
|
}
|
||||||
if (isset($cache) && isset($guid)) {
|
if (isset($cache) && isset($guid)) {
|
||||||
// 缓存数据
|
// 缓存数据
|
||||||
if (isset($cache['tag'])) {
|
$this->cacheData($guid, $result, $cache);
|
||||||
Cache::tag($cache['tag'])->set($guid, $result, $cache['expire']);
|
|
||||||
} else {
|
|
||||||
Cache::set($guid, $result, $cache['expire']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 清空查询条件
|
// 清空查询条件
|
||||||
@@ -2308,11 +2300,7 @@ class Query
|
|||||||
|
|
||||||
if (isset($cache)) {
|
if (isset($cache)) {
|
||||||
// 缓存数据集
|
// 缓存数据集
|
||||||
if (isset($cache['tag'])) {
|
$this->cacheData($key, $resultSet, $cache);
|
||||||
Cache::tag($cache['tag'])->set($key, $resultSet, $cache['expire']);
|
|
||||||
} else {
|
|
||||||
Cache::set($key, $resultSet, $cache['expire']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2356,6 +2344,28 @@ class Query
|
|||||||
return $resultSet;
|
return $resultSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存数据
|
||||||
|
* @access public
|
||||||
|
* @param string $key 缓存标识
|
||||||
|
* @param mixed $data 缓存数据
|
||||||
|
* @param array $config 缓存参数
|
||||||
|
*/
|
||||||
|
protected function cacheData($key, $data, $config = [])
|
||||||
|
{
|
||||||
|
if (isset($config['tag'])) {
|
||||||
|
Cache::tag($config['tag'])->set($key, $data, $config['expire']);
|
||||||
|
} else {
|
||||||
|
Cache::set($key, $data, $config['expire']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成缓存标识
|
||||||
|
* @access public
|
||||||
|
* @param mixed $value 缓存数据
|
||||||
|
* @param array $options 缓存参数
|
||||||
|
*/
|
||||||
protected function getCacheKey($value, $options)
|
protected function getCacheKey($value, $options)
|
||||||
{
|
{
|
||||||
if (is_scalar($value)) {
|
if (is_scalar($value)) {
|
||||||
@@ -2443,11 +2453,7 @@ class Query
|
|||||||
|
|
||||||
if (isset($cache)) {
|
if (isset($cache)) {
|
||||||
// 缓存数据
|
// 缓存数据
|
||||||
if (isset($cache['tag'])) {
|
$this->cacheData($key, $result, $cache);
|
||||||
Cache::tag($cache['tag'])->set($key, $result, $cache['expire']);
|
|
||||||
} else {
|
|
||||||
Cache::set($key, $result, $cache['expire']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user