//pdo/mysql和redis断线重连的实现
//TODO:DB初始化
$pdo = new \PDO($this->dbConfig['dsn'], $this->dbConfig["username"], $this->dbConfig["password"],array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION));
$pdo->exec("SET NAMES '" . $this->dbConfig["charset"] . "' COLLATE '" . $this->dbConfig["collation"] . "'");
$pdo->exec("SET CHARACTER SET '" . $this->dbConfig["charset"] . "'");
$pdo->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_OBJ);
//TODO:redis初始化
$redis = new \Redis();
$redis->pconnect($this->redisConfig['host'], $this->redisConfig['port']);
$redis->auth($this->redisConfig['passwd']);
if(isset($this->redisConfig['options'])){
foreach ($this->redisConfig['options'] as $option=>$value){
pdo/mysql和redis断线重连的实现
最新推荐文章于 2021-03-20 19:52:45 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)