From dab21914d8be7407bdbc2d3d7635dadd42ea2eb9 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 10 Apr 2016 16:40:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BModel=E7=B1=BB=E7=9A=84get?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E7=BC=93=E5=AD=98=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 80274326..54bcd4b4 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -619,7 +619,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess if ($cache) { // 查找是否存在缓存 $name = basename(str_replace('\\', '/', get_called_class())); - $guid = 'model_' . $name . '_' . $data; + $guid = md5('model_' . $name . '_' . serialize($data)); $result = Cache::get($guid); if ($result) { return new static($result); @@ -628,7 +628,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess $result = $db->find($data); - if ($cache) { + if ($cache && $result instanceof Model) { // 缓存模型数据 Cache::set($guid, $result->toArray()); }