Add "redis-sentinel" as an available queue connection driver option to
the Laravel queue manager using Horizon's modified Redis connector.

@return void
341945
protected function addHorizonSentinelQueueConnector()
    {
        $this->app->make('queue')->extend('redis-sentinel', function () {
            $redis = $this->app->make('redis-sentinel.manager');

            return new HorizonRedisConnector($redis);
        });
    }
1351359
public function getRedis(): ?Connection
    {
        if (!$this->hasRedis()) {
            $this->setRedis($this->getDefaultRedis());
        }
        return $this->redis;
    }
591157
public function onReady()
    {
        $this->redis = \PHPDaemon\Clients\Redis\Pool::getInstance();

        $params = [];
        foreach (range(0, 100) as $i) {
            $params[] = 'myset' . $i;
            $params[] = 'value' . $i;
        }
        $params[] = function ($redis) {
            $params = [
                function ($redis) {
                    D('Count: ' . count($redis->result[1]) . '; Next: ' . $redis->result[0]);
                }
            ];

            $cbEnd = function ($redis, $scan) {
                D('Full scan end!');
            };

            // test 1
            // $this->redis->scan(...$params);

            // test 2
            $this->redis->autoscan('scan', $params, $cbEnd, 50);
        };
        $this->redis->mset(...$params);
    }
1219573
protected function addRedisSentinelCacheStore()
    {
        $cache = $this->app->make('cache');

        $cache->extend('redis-sentinel', function ($app, $conf) use ($cache) {
            $redis = $app->make('redis-sentinel.manager');
            $prefix = $app->make('config')->get('cache.prefix');
            $connection = Arr::get($conf, 'connection', 'default');
            $store = new RedisStore($redis, $prefix, $connection);

            return $cache->repository($store);
        });
    }
624646
protected function registerSwooleQueueDriver()
    {
        $this->app->afterResolving('queue', function (QueueManager $manager) {
            $manager->addConnector('swoole', function () {
                return new SwooleTaskConnector($this->app->make(Server::class));
            });
        });
    }
602946
protected function connect()
    {
        if (!is_object(self::$instance)) {
            $func = $this->options['persistent'] ? 'pconnect' : 'connect';

            self::$instance = new \Redis();
            self::$instance->$func($this->options['host'], $this->options['port'], $this->options['timeout']);

            if ('' != $this->options['password']) {
                self::$instance->auth($this->options['password']);
            }
            if (0 != $this->options['select']) {
                self::$instance->select($this->options['select']);
            }
        }
    }
1016085
protected function _init() {
		if (!$this->connection) {
			$this->connection = new RedisCore();
		}
		$method = $this->_config['persistent'] ? 'pconnect' : 'connect';

		if (HostString::isSocket($this->_config['host'])) {
			$this->connection->{$method}($this->_config['host']);
		} else {
			$host = HostString::parse($this->_config['host']) + [
				'host' => static::DEFAULT_HOST,
				'port' => static::DEFAULT_PORT
			];
			$this->connection->{$method}($host['host'], $host['port']);
		}

		if ($this->_config['scope']) {
			$this->connection->setOption(RedisCore::OPT_PREFIX, "{$this->_config['scope']}:");
		}
	}
578771
protected function loadPackageConfiguration()
    {
        if ($this->isLumen) {
            $this->configureLumenComponents();
        }

        $this->setConfigurationFor('database.redis-sentinel');
        $this->setConfigurationFor('database.redis.driver');
        $this->setConfigurationFor('broadcasting.connections.redis-sentinel');
        $this->setConfigurationFor('cache.stores.redis-sentinel');
        $this->setConfigurationFor('queue.connections.redis-sentinel');
        $this->setSessionConfiguration();

        $this->normalizeHosts();

        $this->cleanPackageConfiguration();
    }
22889
def _setup_redis(self):
        """"""
        if not self.closed:
            try:
                self.logger.debug("Creating redis connection to host " +
                                  str(self.settings['REDIS_HOST']))
                self.redis_conn = redis.StrictRedis(host=self.settings['REDIS_HOST'],
                                              port=self.settings['REDIS_PORT'],
                                              db=self.settings['REDIS_DB'])
                self.redis_conn.info()
                self.redis_connected = True
                self.logger.info("Successfully connected to redis")
            except KeyError as e:
                self.logger.error('Missing setting named ' + str(e),
                                   {'ex': traceback.format_exc()})
            except:
                self.logger.error("Couldn't initialize redis client.",
                                   {'ex': traceback.format_exc()})
                raise
548862
private function connect()
	{
		// We want to only create the driver once.
		if ($this->driver)
		{
			return;
		}

		$pool = $this->options['memcache.pool'];

		if ($pool)
		{
			$this->driver = new \Memcached($pool);
		}
		else
		{
			$this->driver = new \Memcached;
		}

		$this->driver->setOption(\Memcached::OPT_COMPRESSION, $this->options['memcache.compress'] ?: false);
		$this->driver->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
		$serverList = $this->driver->getServerList();

		// If we are using a persistent pool we don't want to add the servers again.
		if (empty($serverList))
		{
			$servers = $this->options['memcache.servers'] ?: array();

			foreach ($servers as $server)
			{
				$this->driver->addServer($server->host, $server->port);
			}
		}
	}
742463
private function connect()
    {
        $memcache = new Memcached();
        $memcache->addServer($this->host, $this->port);

        if (null !== $this->prefix) {
            $memcache->setOption(Memcached::OPT_PREFIX_KEY, $this->prefix);
        }

        $this->memcached = $memcache;
    }
1220230
protected function addRedisSentinelBroadcaster()
    {
        $this->app->make(BroadcastFactory::class)
            ->extend('redis-sentinel', function ($app, $conf) {
                $redis = $app->make('redis-sentinel.manager');
                $connection = Arr::get($conf, 'connection', 'default');

                return new RedisBroadcaster($redis, $connection);
            });
    }
147714
public function getConnection()
    {
        if (null === $this->connection) {
            $this->connection = new \Redis();

            if (!$this->connection->pconnect(
                $this->config['default']['host'],
                $this->config['default']['port']
            )) {
                throw new \RedisException('Unable to connect');
            }
        }

        return $this->connection;
    }
543708
protected function rebindHorizonRedisFactory()
    {
        // Although not all of the classes that Horizon registers need an
        // instance of the Redis service, we'll set up contextual bindings
        // for any declared so we don't need to update this package in the
        // future every time Horizon adds or removes one:
        foreach ((new HorizonServiceBindings()) as $serviceClass) {
            $this->app->when($serviceClass)
                ->needs(RedisFactory::class)
                ->give(function () {
                    return $this->app->make('redis-sentinel.manager');
                });
        }
    }
591921
private function addRedisNode()
    {
        $builder = new TreeBuilder();
        $node = $builder->root('redis');

        $node
            ->addDefaultsIfNotSet()
            ->children()
                ->scalarNode('connection_id')->defaultNull()->end()
                ->scalarNode('host')->defaultValue('127.0.0.1')->end()
                ->scalarNode('port')->defaultValue('6379')->end()
                ->scalarNode('password')->defaultNull()->end()
                ->scalarNode('timeout')->defaultNull()->end()
                ->scalarNode('database')->defaultNull()->end()
            ->end();

        return $node;
    }
1063730
def _spawn_redis_connection_thread(self):
        """"""
        self.logger.debug("Spawn redis connection thread")
        self.redis_connected = False
        self._redis_thread = Thread(target=self._setup_redis)
        self._redis_thread.setDaemon(True)
        self._redis_thread.start()
1078065
public function bootAfterAll(): void
    {
        /** @var QueueManager $queue */
        $queue = app('queue');

        // Add database Connector
        $queue->addConnector('database', function () {
            return new DatabaseConnector($this->app['db']);
        });

        // Add RabbitMq Connector
        if (!empty($this->app->getProviders('VladimirYuldashev\LaravelQueueRabbitMQ\LaravelQueueRabbitMQServiceProvider'))) {
            $queue->addConnector('rabbitmq', function () {
                return new RabbitMQConnector($this->app['events']);
            });
        }

        if (!empty($this->app->getProviders('Laravel\Horizon\HorizonServiceProvider'))) {
            // Add horizon Connector
            $queue->addConnector('redis', function () {
                return new HorizonConnector($this->app['redis']);
            });
        } else {
            // Add Redis Connector
            $queue->addConnector('redis', function () {
                return new RedisConnector($this->app['redis']);
            });
        }
    }