获取Redis操作对象
@param RedisModel $redisModel
@return \Redis
429217
public static function __getRedis(RedisModel $redisModel = null)
    {
        $annotation = ModelManager::getRedisEntity(null === $redisModel ? static::class : $redisModel);
        $redis = PoolManager::getRequestContextResource($annotation->poolName)->getInstance();
        if(null !== $annotation->db)
        {
            $redis->select($annotation->db);
        }
        return $redis;
    }
1351359
public function getRedis(): ?Connection
    {
        if (!$this->hasRedis()) {
            $this->setRedis($this->getDefaultRedis());
        }
        return $this->redis;
    }
838585
public static function cluster(array $config = []): RedisInterface
    {
        $driver = $config['driver'] ?? '';

        if ($driver === 'native' || !PHP_REDIS_EXTENSION) {
            return new Cluster\Native($config);
        }

        return new Cluster\PhpRedis($config);
    }
1213919
private function connection__redis() {
		$this->connection = new \Redis();
		# @note: This emits warning on failure instead of throwing
		# exception, hence the @ sign.
		if (!@$this->connection->connect(
			$this->redishost, $this->redisport,
			$this->redistimeout
		))
			// @codeCoverageIgnoreStart
			return $this->connection_open_fail();
			// @codeCoverageIgnoreEnd
		if ($this->redispassword || $this->redisdatabase) {
			try {
				if ($this->redispassword)
					$this->connection->auth($this->redispassword);
				if ($this->redisdatabase)
					$this->connection->select($this->redisdatabase);
			} catch(\RedisException $e) {
				return $this->connection_open_fail($e->getMessage());
			}
		}
		try {
			$this->connection->ping();
		} catch(\RedisException $e) {
			return $this->connection_open_fail($e->getMessage());
		}
		return $this->connection_open_ok();
	}
969794
protected function createRedisDriver()
    {
        $serverArray    = $this->config['servers'];
        $persistent     = boolval($this->config['persistent']);
        $prefix         = trim($this->config['prefix']);
        $expireTime     = intval($this->config['lifetime']);

        if ($persistent) {
            foreach ($serverArray as $k => $v) {
                $v['persistent']    = true;
                $serverArray[$k]    = $v;
            }
        }

        $redisServer    = new RedisServer($serverArray);
        $redisStore     = new RedisStore($redisServer, $prefix);
        return new CacheSessionHandler($redisStore, $expireTime);
    }
441688
public function index()
    {
        return Admin::content(function (Content $content) {
            $content->header('Redis manager');
            $content->description('Connections');
            $content->breadcrumb(['text' => 'Redis manager']);

            $connection = request('conn', 'default');

            $manager = $this->manager();

            $variables = [
                'conn'        => $connection,
                'info'        => $manager->getInformation(),
                'connections' => $manager->getConnections(),
                'keys'        => $manager->scan(
                    request('pattern', '*'),
                    request('count', 50)
                ),
            ];

            $content->body(view('laravel-admin-redis-manager::index', $variables));
        });
    }
931734
protected function getClusterClient(string $serverInfo): Redis
	{
		[, $server] = explode(' ', $serverInfo, 2);

		if(!isset($this->clusterClients[$server]))
		{
			$this->clusterClients[$server] = $this->createClusterClient($server);
		}

		return $this->clusterClients[$server];
	}
507694
public function getSync()
    {
        if ($this->redis_client != null) {
            return $this->redis_client;
        }
        //同步redis连接，给task使用
        $this->redis_client = new \Redis();
        if ($this->redis_client->connect($this->config['redis'][$this->active]['ip'], $this->config['redis'][$this->active]['port']) == false) {
            throw new SwooleException($this->redis_client->getLastError());
            $this->redis_client = null;
        }
        if (!empty($this->config->get('redis.' . $this->active . '.password', ""))) {//存在验证
            if ($this->redis_client->auth($this->config['redis'][$this->active]['password']) == false) {
                throw new SwooleException($this->redis_client->getLastError());
                $this->redis_client = null;
            }
        }
        if ($this->config->has('redis.' . $this->active . '.select')) {//存在select
            $this->redis_client->select($this->config['redis'][$this->active]['select']);
        }
        return $this->redis_client;
    }
1329239
public function redis($name, Child $parent)
    {
        if (empty($name)) {
            return null;
        }
        if($parent->root == null){
            $parent->root = $parent;
        }
        $root = $parent->root;
        $core_name = RedisAsynPool::AsynName . ":" .$name;
        if ($root->hasChild($core_name)) {
            return AOP::getAOP($root->getChild($core_name));
        }
        $redisPool = get_instance()->getAsynPool($name);
        if($redisPool == null) return null;
        $redis = $redisPool->getCoroutine();
        $redis->setContext($root->getContext());
        $root->addChild($redis);
        return AOP::getAOP($redis);
    }
218220
public function redirect($redirectUrl = null)
    {
        $state = null;

        if (!is_null($redirectUrl)) {
            $this->redirectUrl = $redirectUrl;
        }

        if ($this->usesState()) {
            $state = $this->makeState();
        }

        return new RedirectResponse($this->getAuthUrl($state));
    }
1157670
public function setZaddUnit(ZaddUnit $ZaddUnit): RedisZaddFixnum
    {
        $redisRunLog = new RedisRunLog($this);
        $this->getRedisClient()->zadd($this->getKey(), $ZaddUnit->getScore(), $ZaddUnit->getName());
        $redisRunLog
            ->setMethod(__METHOD__)
            ->__invoke();
        return $this;
    }
1072244
public function configure(Redis $redis, OptionsBag $conn)
    {
        if ($conn['persistent']) {
            $redis->pconnect($conn['host'], $conn['port'], $conn['timeout']);
        } else {
            $redis->connect($conn['host'], $conn['port'], $conn['timeout'], $conn['retry_interval']);
        }

        if ($conn['password']) {
            $redis->auth($conn['password']);
        }

        if ($conn['database'] >= 0) {
            $redis->select($conn['database']);
        }

        if ($conn['prefix']) {
            $redis->setOption(Redis::OPT_PREFIX, $conn['prefix']);
        }

        return $redis;
    }
1018937
public static function Redis($host = '127.0.0.1', $port = 6379, $options = [])
    {
        return new CacheStorage(Storage\Redis::getInstance($host, $port), $options);
    }
480067
def redis
      @redis ||= (
        url = URI(@redis_url || ENV["REDIS_URL"] || "redis://127.0.0.1:6379/0")

        ::Redis.new({
          :host => url.host,
          :port => url.port,
          :db => url.path[1..-1],
          :password => url.password
        })
      )
    end
271982
private function getRedisConnection(array $config)
    {
        $redis = new \Redis();
        $host = isset($config['host']) ? $config['host'] : 'localhost';

        if (isset($config['port'])) {
            $redis->connect($host, $config['port']);
        } else {
            $redis->connect($host);
        }

        return $redis;
    }
1187523
public function get()
    {
        $redis = new Redis;
        $redis->connect($this->config['host'], $this->config['port']);
        $redis->setOption(Redis::OPT_READ_TIMEOUT, -1);
        if ($this->config['database']) {
            $redis->select($this->config['database']);
        }

        return $redis;
    }
588682
public function getSlaveConnection()
    {
        if (null === $this->slaveConnection) {
            $this->slaveConnection = new \Redis();
            $this->slaveConnection->pconnect(
                $this->config['slave']['HOST'],
                $this->config['slave']['PORT']
            );
        }
        return $this->slaveConnection;
    }