diff --git a/library/think/Model.php b/library/think/Model.php index e4306697..cb7bd21f 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -985,9 +985,6 @@ abstract class Model implements \JsonSerializable, \ArrayAccess */ public static function get($data = null, $with = [], $cache = false) { - if (!$cache && $data && is_scalar($data)) { - $cache = true; - } $query = static::parseQuery($data, $with, $cache); return $query->find($data); } diff --git a/library/think/db/Query.php b/library/think/db/Query.php index a3e8ac2e..f49d7d3d 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -1769,6 +1769,10 @@ class Query { $options = $this->parseExpress(); $pk = $this->getPk($options); + if (isset($options['cache']) && is_string($options['cache'])) { + $key = $options['cache']; + } + if (empty($options['where'])) { // 如果存在主键数据 则自动作为更新条件 if (is_string($pk) && isset($data[$pk])) { @@ -2095,6 +2099,9 @@ class Query { // 分析查询表达式 $options = $this->parseExpress(); + if (isset($options['cache']) && is_string($options['cache'])) { + $key = $options['cache']; + } if (!is_null($data) && true !== $data) { if (!is_array($data)) {