public function getRedisConnection(array $options = [])
    {
        $options = array_replace(['host' => 'localhost', 'port' => 6379], $options);
        if (null !== $cache = $this->getConnection('redis', $options)) {
            return $cache;
        }

        if (!extension_loaded('redis')) {
            throw new RuntimeException('The Redis cache requires the Redis extension.');
        }

        $redis = new \Redis();

        if (!@$redis->connect($options['host'], $options['port'])) {
            throw new RuntimeException(sprintf("Redis instance with host '%s' and port '%s' is not reachable.", $options['host'], $options['port']));
        }
        if (!defined('Redis::SERIALIZER_IGBINARY') || !$redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_IGBINARY)) {
            $redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_PHP);
        }

        return $this->setConnection('redis', $options, $redis);
    }
public function getRedisConnection(array $options = [])
    {
        $options = array_replace(['host' => 'localhost', 'port' => 6379], $options);
        if (null !== $cache = $this->getConnection('redis', $options)) {
            return $cache;
        }

        if (!extension_loaded('redis')) {
            throw new RuntimeException('The Redis cache requires the Redis extension.');
        }

        $redis = new \Redis();

        if (!@$redis->connect($options['host'], $options['port'])) {
            throw new RuntimeException(sprintf("Redis instance with host '%s' and port '%s' is not reachable.", $options['host'], $options['port']));
        }
        if (!defined('Redis::SERIALIZER_IGBINARY') || !$redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_IGBINARY)) {
            $redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_PHP);
        }

        return $this->setConnection('redis', $options, $redis);
    }
public function getRedisConnection ( array $ options = [ ] ) { $ options = array_replace ( [ 'host' => 'localhost' , 'port' => 6379 ] , $ options ) ; if ( null !== $ cache = $ this -> getConnection ( 'redis' , $ options ) ) { return $ cache ; } if ( ! extension_loaded ( 'redis' ) ) { throw new RuntimeException ( 'The Redis cache requires the Redis extension.' ) ; } $ redis = new \ Redis ( ) ; if ( ! @ $ redis -> connect ( $ options [ 'host' ] , $ options [ 'port' ] ) ) { throw new RuntimeException ( sprintf ( "Redis instance with host '%s' and port '%s' is not reachable." , $ options [ 'host' ] , $ options [ 'port' ] ) ) ; } if ( ! defined ( 'Redis::SERIALIZER_IGBINARY' ) || ! $ redis -> setOption ( \ Redis :: OPT_SERIALIZER , \ Redis :: SERIALIZER_IGBINARY ) ) { $ redis -> setOption ( \ Redis :: OPT_SERIALIZER , \ Redis :: SERIALIZER_PHP ) ; } return $ this -> setConnection ( 'redis' , $ options , $ redis ) ; }
Returns a Redis connection.

@param array $options Available options are 'host' and 'port'

@return \Redis

@throws RuntimeException
Returns a Redis connection .