Get a Redis connection by name.

@param  string|null  $name
@return \Illuminate\Redis\Connections\Connection
492117
public function connection($name = null)
    {
        $name = $name ?: 'default';

        if (isset($this->connections[$name])) {
            return $this->connections[$name];
        }

        return $this->connections[$name] = $this->configure(
            $this->resolve($name), $name
        );
    }
816627
public function getConnection($name = null, $forceNew = false) {
		if (!$forceNew && isset($this->connections[$name])) {
			return $this->connections[$name];
		}

		$config = $this->getConnectionConfig($name);

		if (!$config) {
			return null;
		}

		$pdoArgs = [$config['dsn'], $config['username'], $config['password']];
		$options = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];

		if (isset($config['options'])) {
			$options = $config['options'] + $options;
		}
		$pdoArgs[] = $options;

		$this->connections[$name] = new PDO(...$pdoArgs);

		return $this->connections[$name];
	}
1031382
public static function get( $name = null ) {
		if ( is_null( $name ) ) {
			return self::$data;
		}

		if ( isset( self::$data[ $name ] ) ) {
			return self::$data[ $name ];
		}

		return null;
	}
297581
public function &__get($name)
    {
        if (!Arr::keyExists($this->data, $name))
        {
            $this->data[$name] = null;
        }

        return $this->data[$name];
    }
1153140
public function getConnection($name)
    {
        if (!$this->hasConnection($name)) {
            throw new \InvalidArgumentException(sprintf('The connection "%s" does not exist.', $name));
        }

        return $this->connections[$name];
    }
190938
public static function get($name = null)
    {
        if ($name === null) {
            $name = array_shift(array_keys(self::$containers));
        }
        return self::$containers[$name] ? self::$containers[$name] : null;
    }
592318
public function connection($name = null)
    {
        $name = $name ?: $this->getDefaultDriver();

        // If the connection has not been resolved yet we will resolve it now as all
        // of the connections are resolved when they are actually needed so we do
        // not make any unnecessary connection to the various queue end-points.
        if ( ! isset($this->connections[$name])) {
            $this->connections[$name] = $this->resolve($name);

            $this->connections[$name]->setContainer($this->app);

            $this->connections[$name]->setEncrypter($this->app['encrypter']);
        }

        return $this->connections[$name];
    }
125121
public function getConnection($name = 'default')
    {
        if (array_key_exists($name, $this->connections)) {
            return $this->connections[$name];
        }
        return null;
    }
1351783
public function reconnect($name = null)
    {
        $this->disconnect($name = $name ?: $this->getDefaultConnection());

        if (!isset($this->connections[$name])) {
            return $this->connection($name);
        } else {
            return $this->refreshPdoConnections($name);
        }
    }
1011449
public static function connection($name)
    {
        if (self::$conn_list === null) {
            self::init();
        }

        $name = strval($name);

        if (! isset(self::$conn_list[$name])) {
            throw new \InvalidArgumentException("找不到连接名为'{$name}'的Redis配置！请检查配置项'database.redis'");
        }

        return self::getConnection($name);
    }
318599
public function connection(string $name = null): Connection
    {
        $name = $name ?? $this->getDefaultConnection();

        if (! isset($this->connections[$name])) {
            throw new InvalidArgumentException("Connection [$name] not configured.");
        }

        return $this->connections[$name];
    }
677806
public function getConnection($name)
	{
		if (array_key_exists($name, $this->_connections))
			return $this->_connections[$name];

		return null;
	}
1251032
public function getConnection($name = ''): QueryBuilderInterface
	{
		// If the parameter is a string, use it as an array index
		if (is_scalar($name) && isset($this->connections[$name]))
		{
			return $this->connections[$name];
		}
		else if (empty($name) && ! empty($this->connections)) // Otherwise, return the last one
		{
			return end($this->connections);
		}

		// You should actually connect before trying to get a connection...
		throw new InvalidArgumentException('The specified connection does not exist');
	}
642657
public static function get($name)
    {
        if (isset(self::$_cached_settings[$name])) {
            return self::$_cached_settings[$name];
        }
        return NULL;
    }
992486
public function getByName($name)
    {
        if (!isset($this->nameMap[$name])) {
            return null;
        }

        return $this->get($this->nameMap[$name]);
    }
1191214
protected function _getConnection( $name )
	{
		if( !isset( $this->_connections[$name] ) ) {
			return $this->_conn;
		}

		return $this->_connections[$name];
	}
1276648
public function connection($name = null)
	{
		list($database, $type) = $this->parseConnectionName($name);
		$name = $name ?: $database;

		// If we haven't created this connection, we'll create it based on the config
		// provided in the application. Once we've created the connections we will
		// set the "fetch mode" for PDO which determines the query return types.
		if (! isset($this->connections[$name]))
		{
			$this->connections[$name] = $this->configure(
				$this->makeConnection($database), $type
			);
		}

		return $this->connections[$name];
	}