config配置
/*redis链接*/
'redis' => [
'default' => [
'type' => 'redis',
'debug' => true,
'hostname' => '127.0.0.1',
'port' => 6379,
'auth' => '',
'timeout' => 3,//单位秒
'pconnect' => 0,
'autoconnect' => 0
]
],
使用
$arrConfig = Config::get('redis.default');
$objRedis = new Redis();
if(!$arrConfig['pconnect'])
$objRedis->connect($arrConfig['hostname'], $arrConfig['port'],$arrConfig['timeout']);
else
$objRedis->pconnect($arrConfig['hostname'], $arrConfig['port'],$arrConfig['timeout']);
$objRedis->auth($arrConfig['auth']);
if(!$objRedis) parent::returnCode(1999,'数据库连接失败!');
return $objRedis;
##config.php
/*redis链接*/
'redis' => [
'default' => [
'type' => 'redis',
'debug' => true,
'hostname' => '127.0.0.1',
'port' => 6379,
'auth' => '',
'timeout' => 3,//单位秒
'pconnect' => 0,
'autoconnect' => 0
]
],