Redis.php 828 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace App\Com;
  3. use EasySwoole\EasySwoole\Config;
  4. use EasySwoole\Redis\Config\RedisConfig;
  5. class Redis
  6. {
  7. private static $instance;
  8. protected $connect; //Redis连接实例
  9. static function getInstance(){
  10. if(!isset(self::$instance)){
  11. self::$instance = new static();
  12. }
  13. return self::$instance;
  14. }
  15. function __construct()
  16. {
  17. $db_config = Config::getInstance()->getConf('REDIS');
  18. $config = new RedisConfig($db_config);
  19. $this->connect = new \EasySwoole\Redis\Redis($config);
  20. // $this->connect->connect($db_config['host'], $db_config['port']); //连接Redis
  21. // $this->connect->auth($db_config['auth']); //密码验证
  22. }
  23. public function getConnect(){
  24. return $this->connect;
  25. }
  26. public function get($key) {
  27. }
  28. }