修正model类的cache方法

This commit is contained in:
thinkphp
2015-12-13 10:52:56 +08:00
parent 0dc706b82c
commit 1a902f92cd

View File

@@ -459,7 +459,7 @@ class Model
if (isset($options['cache'])) { if (isset($options['cache'])) {
$cache = $options['cache']; $cache = $options['cache'];
$key = is_string($cache['key']) ? $cache['key'] : md5(serialize($options)); $key = is_string($cache['key']) ? $cache['key'] : md5(serialize($options));
$data = Cache::get($key, '', $cache); $data = Cache::get($key);
if (false !== $data) { if (false !== $data) {
return $data; return $data;
} }
@@ -493,7 +493,7 @@ class Model
} }
if (isset($cache)) { if (isset($cache)) {
Cache::set($key, $resultSet, $cache); Cache::set($key, $resultSet, $cache['expire']);
} }
return $resultSet; return $resultSet;
@@ -641,7 +641,7 @@ class Model
if (isset($options['cache'])) { if (isset($options['cache'])) {
$cache = $options['cache']; $cache = $options['cache'];
$key = is_string($cache['key']) ? $cache['key'] : md5(serialize($options)); $key = is_string($cache['key']) ? $cache['key'] : md5(serialize($options));
$data = Cache::get($key, '', $cache); $data = Cache::get($key);
if (false !== $data) { if (false !== $data) {
$this->data = $data; $this->data = $data;
return $data; return $data;
@@ -663,7 +663,7 @@ class Model
// 数据对象赋值 // 数据对象赋值
$this->data = $data; $this->data = $data;
if (isset($cache)) { if (isset($cache)) {
Cache::set($key, $data, $cache); Cache::set($key, $data, $cache['expire']);
} }
return $this->data; return $this->data;
} }