/** * 获取redis实例 * @return \Redis */ protected function getRedis() { if (empty($this->redis) || !$this->redis->info()) { $this->redis = new \Redis(); if (empty($this->config)) { $this->config = \Config\Redis::getSessionConfig(); } $res = $this->redis->connect($this->config['host'], $this->config['port']); $this->redis->select($this->config['database']); if (empty($res)) { echo "connect Redis failed!\n"; } } return $this->redis; }