mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 23:02:48 +08:00
改进查询缓存
This commit is contained in:
@@ -403,7 +403,7 @@ class Query
|
|||||||
if (empty($this->options['table'])) {
|
if (empty($this->options['table'])) {
|
||||||
$this->options['table'] = $this->getTable();
|
$this->options['table'] = $this->getTable();
|
||||||
}
|
}
|
||||||
$key = is_string($cache['key']) ? $cache['key'] : md5($field . serialize($this->options) . serialize($this->bind));
|
$key = is_string($cache['key']) ? $cache['key'] : md5($this->connection->getConfig('database') . '.' . $field . serialize($this->options) . serialize($this->bind));
|
||||||
$result = Cache::get($key);
|
$result = Cache::get($key);
|
||||||
}
|
}
|
||||||
if (false === $result) {
|
if (false === $result) {
|
||||||
@@ -447,7 +447,7 @@ class Query
|
|||||||
if (empty($this->options['table'])) {
|
if (empty($this->options['table'])) {
|
||||||
$this->options['table'] = $this->getTable();
|
$this->options['table'] = $this->getTable();
|
||||||
}
|
}
|
||||||
$guid = is_string($cache['key']) ? $cache['key'] : md5($field . serialize($this->options) . serialize($this->bind));
|
$guid = is_string($cache['key']) ? $cache['key'] : md5($this->connection->getConfig('database') . '.' . $field . serialize($this->options) . serialize($this->bind));
|
||||||
$result = Cache::get($guid);
|
$result = Cache::get($guid);
|
||||||
}
|
}
|
||||||
if (false === $result) {
|
if (false === $result) {
|
||||||
@@ -2322,7 +2322,7 @@ class Query
|
|||||||
// 判断查询缓存
|
// 判断查询缓存
|
||||||
$cache = $options['cache'];
|
$cache = $options['cache'];
|
||||||
unset($options['cache']);
|
unset($options['cache']);
|
||||||
$key = is_string($cache['key']) ? $cache['key'] : md5(serialize($options) . serialize($this->bind));
|
$key = is_string($cache['key']) ? $cache['key'] : md5($this->connection->getConfig('database') . '.' . serialize($options) . serialize($this->bind));
|
||||||
$resultSet = Cache::get($key);
|
$resultSet = Cache::get($key);
|
||||||
}
|
}
|
||||||
if (false === $resultSet) {
|
if (false === $resultSet) {
|
||||||
@@ -2463,11 +2463,11 @@ class Query
|
|||||||
// 判断查询缓存
|
// 判断查询缓存
|
||||||
$cache = $options['cache'];
|
$cache = $options['cache'];
|
||||||
if (true === $cache['key'] && !is_null($data) && !is_array($data)) {
|
if (true === $cache['key'] && !is_null($data) && !is_array($data)) {
|
||||||
$key = 'think:' . (is_array($options['table']) ? key($options['table']) : $options['table']) . '|' . $data;
|
$key = 'think:' . $this->connection->getConfig('database') . '.' . (is_array($options['table']) ? key($options['table']) : $options['table']) . '|' . $data;
|
||||||
} elseif (is_string($cache['key'])) {
|
} elseif (is_string($cache['key'])) {
|
||||||
$key = $cache['key'];
|
$key = $cache['key'];
|
||||||
} elseif (!isset($key)) {
|
} elseif (!isset($key)) {
|
||||||
$key = md5(serialize($options) . serialize($this->bind));
|
$key = md5($this->connection->getConfig('database') . '.' . serialize($options) . serialize($this->bind));
|
||||||
}
|
}
|
||||||
$result = Cache::get($key);
|
$result = Cache::get($key);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user