Model类get方法使用主键查询自动缓存

This commit is contained in:
thinkphp
2016-08-16 22:39:53 +08:00
parent 8d32fcce08
commit f3ff63268a
2 changed files with 6 additions and 1 deletions

View File

@@ -985,6 +985,9 @@ 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);
}