Skip to content

Commit 715e55d

Browse files
committed
改进查询缓存标识自动获取
1 parent 6a38636 commit 715e55d

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/db/BaseQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ public function cache($key = true, $expire = null, $tag = null)
10061006
$key = true;
10071007
}
10081008

1009-
$this->options['cache'] = [$key, $expire, $tag ?: $this->getTable()];
1009+
$this->options['cache'] = [$key, $expire, $tag ?: var_export($this->getTable(), true)];
10101010
return $this;
10111011
}
10121012

src/db/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ protected function cacheData(CacheItem $cacheItem)
320320
protected function getCacheKey(BaseQuery $query, string $method = ''): string
321321
{
322322
if (!empty($query->getOptions('key')) && empty($method)) {
323-
$key = 'think_' . $this->getConfig('database') . '.' . $query->getTable() . '|' . $query->getOptions('key');
323+
$key = 'think_' . $this->getConfig('database') . '.' . var_export($query->getTable(), true) . '|' . $query->getOptions('key');
324324
} else {
325325
$key = $query->getQueryGuid();
326326
}

src/db/Query.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ public function getQueryGuid($data = null): string
521521
{
522522
if (null === $data) {
523523
$data = $this->options;
524-
$data['table'] = $this->getConfig('database') . $this->getTable();
524+
$data['table'] = $this->getConfig('database') . var_export($this->getTable(), true);
525525
unset($data['scope'], $data['default_model']);
526526
foreach (['AND', 'OR', 'XOR'] as $logic) {
527527
if (isset($data['where'][$logic])) {

0 commit comments

Comments
 (0)