123456789101112131415161718192021222324252627282930 |
- <?php
- namespace App\Com;
- use EasySwoole\EasySwoole\Config;
- class Redis
- {
- private static $instance;
- protected $connect; //Redis连接实例
- static function getInstance(){
- if(!isset(self::$instance)){
- self::$instance = new static();
- }
- return self::$instance;
- }
- function __construct()
- {
- $db_config = Config::getInstance()->getConf('REDIS');
- $this->connect = new \Redis();
- $this->connect->connect($db_config['host'], $db_config['port']); //连接Redis
- $this->connect->auth($db_config['auth']); //密码验证
- }
- public function getConnect(){
- return $this->connect;
- }
- }
|