/** * getRedis [redis实例] * @author wangzhiqiang * @return \Redis */ private function getRedis() { if (empty($this->redis) || !$this->redis->info()) { $this->redis = new \Redis(); $config = Config::get_redis_config(); $res = $this->redis->connect($config['host'], $config['port']); $this->redis->auth($config['password']); if (!$res) { } } return $this->redis; }
/** * getRedis [reids实例] * @author wangzhiqiang * @param int $id * @return mixed */ public function getRedis($id = 0) { if (empty($this->redis[$id]) || !$this->redis[$id]->info()) { $this->redis[$id] = new \Redis(); $config = Config::get_redis_config(); $res = $this->redis[$id]->connect($config['host'], $config['port']); $this->redis[$id]->auth($config['password']); $this->redis[$id]->select($id); if (!$res) { } } return $this->redis[$id]; }