Cache类的get方法增加默认值参数

This commit is contained in:
thinkphp
2016-07-24 21:56:00 +08:00
parent bab4398552
commit 760b1d971d
11 changed files with 42 additions and 38 deletions

View File

@@ -213,11 +213,12 @@ class Redisd
* 读取缓存
*
* @access public
* @param string $name 缓存key
* @param bool $master 指定主从节点,可以从主节点获取结果
* @param string $name 缓存key
* @param string $default 默认值
* @param bool $master 指定主从节点,可以从主节点获取结果
* @return mixed
*/
public function get($name, $master = false)
public function get($name, $default = false, $master = false)
{
$this->master($master);
@@ -225,14 +226,12 @@ class Redisd
$value = $this->handler->get($name);
} catch (\RedisException $e) {
unset(self::$redis_rw_handler[0]);
$this->master();
return $this->get($name);
return $this->get($name, $default);
} catch (\Exception $e) {
Log::record($e->getMessage(), Log::ERROR);
}
return isset($value) ? $value : null;
return isset($value) ? $value : $default;
}
/**