Connect the redis server and set redis options

@return bool true on success, false on error
7894
public function connect()
    {
        if ($this->object) {
            return true;
        }

        $this->object = new \Redis;
        $connect = $this->persistent ? 'pconnect' : 'connect';
        $result = $this->object->$connect($this->host, $this->port, $this->timeout);

        if ($result && $this->auth) {
            $result = $this->object->auth($this->auth);
        }

        if ($result) {
            foreach ($this->options as $key => $value) {
                $this->object->setOption($key, $value);
            }
        }

        return $result;
    }
1151924
public function connect()
    {
        $this->connection = ftp_connect($this->host);
        if (ftp_login($this->connection, $this->username, $this->password)) {
            if (ftp_chdir($this->connection, $this->getChdir()) && ftp_pasv($this->connection, $this->passive)) {
                $this->connected = true;
                return true;
            }
        }
        return false;
    }
605220
public function connect()
        {

            $connect = ftp_connect($this->getHost());
            $login = ftp_login($connect, $this->getUsername(), $this->getPassword());

            if(!$login || !$connect){
                return false;
            }else{
                $this->setConnect($connect);
                return $this;
            }

        }
1219208
public function connect($driverOptions = array()) {
        if ($this->pdo === null) {
            if (is_array($driverOptions) && !empty($driverOptions)) {
                $this->config['driverOptions']= array_merge($this->config['driverOptions'], $driverOptions);
            }
            try {
                $this->pdo= new \PDO($this->config['dsn'], $this->config['username'], $this->config['password'], $this->config['driverOptions']);
            } catch (\PDOException $xe) {
                $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, $xe->getMessage(), '', __METHOD__, __FILE__, __LINE__);
                return false;
            } catch (\Exception $e) {
                $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, $e->getMessage(), '', __METHOD__, __FILE__, __LINE__);
                return false;
            }

            $connected= (is_object($this->pdo));
            if ($connected) {
                $connectFile = XPDO_CORE_PATH . 'om/' . $this->config['dbtype'] . '/connect.inc.php';
                if (!empty($this->config['connect_file']) && file_exists($this->config['connect_file'])) {
                    $connectFile = $this->config['connect_file'];
                }
                if (file_exists($connectFile)) include ($connectFile);
            }
            if (!$connected) {
                $this->pdo= null;
            }
        }
        $connected= is_object($this->pdo);
        return $connected;
    }
1195530
protected function setConnectionOptions() {
        $options = $this->sessionVars;
        //$options['time_zone'] = date_default_timezone_get();      // synchronize connection timezone with PHP timezone

        foreach ($options as $option => $value) {
            if (strlen($value)) {
                $this->execute('set '.$option.' to '.$value);       // as is (no quoting)
            }
        }
        return $this;
    }
413392
protected function connect()
    {
        if (!is_object(self::$instance)) {
            self::$instance = new \Memcached();

            if (!empty($this->options['option'])) {
                self::$instance->setOptions($this->options['option']);
            }

            // Set connection timeout ms
            if ($this->options['timeout'] > 0) {
                self::$instance->setOption(\Memcached::OPT_CONNECT_TIMEOUT, $this->options['timeout']);
            }

            // Cluster connections
            $hosts = explode(',', $this->options['host']);
            $ports = explode(',', $this->options['port']);
            if (empty($ports[0])) {
                $ports[0] = 11211;
            }

            // connection establishment
            $servers = [];
            foreach ((array) $hosts as $i => $host) {
                $servers[] = [$host, (isset($ports[$i]) ? $ports[$i] : $ports[0]), 1];
            }

            self::$instance->addServers($servers);

            if ('' != $this->options['username']) {
                self::$instance->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
                self::$instance->setSaslAuthData($this->options['username'], $this->options['password']);
            }
        }
    }
791398
public function connect()
    {
        if ($this->connection) {
            return true;
        }

        $config = $this->config + $this->defaultConfig;

        $dsn = sprintf(
            '%s:host=%s;port=%p;dbname=%s',
            self::DSN_PREFIX,
            $config['host'],
            $config['port'],
            $config['database']
        );

        if ($config['unix_socket']) {
            $dsn = sprintf(
                '%s:unix_socket=%s;dbname=%s',
                self::DSN_PREFIX,
                $config['unix_socket'],
                $config['database']
            );
        }

        $this->connection = new PDO(
            $dsn,
            $config['username'],
            $config['password'],
            $config['options']
        );

        return true;
    }
135747
protected function connect()
    {
        if (!$this->object) {
            $this->object = new \Memcache;
        }
        foreach ($this->servers as $server) {
            call_user_func_array(array($this->object, 'addServer'), $server);
        }
    }
937429
protected function connect()
    {
        $rs = false;

        foreach ((array)$this->server as $svr) {
            $error = 0;
            $errstr = '';
            $rs = @fsockopen($svr['host'], $svr['port'], $error, $errstr);

            if ($rs) {
                $this->socket = $rs;

            } else {
                $key = $this->getServerKey(
                    $svr['host'],
                    $svr['port'],
                    $svr['weight']
                );
                $s = "Connect to $key error:" . PHP_EOL .
                    "    [$error] $errstr";
                error_log($s);
            }
        }

        if (is_null($this->socket)) {
            $this->resultCode = Memcached::RES_FAILURE;
            $this->resultMessage = 'No server avaliable.';
            return false;

        } else {
            $this->resultCode = Memcached::RES_SUCCESS;
            $this->resultMessage = '';
            return true;
        }
    }
928779
protected function configureRedis()
    {
        $config = [
            'REDIS_HOST'     => null,
            'REDIS_DATABASE' => null,
            'REDIS_PORT'     => null,
        ];

        $config['REDIS_HOST'] = $this->ask('What is the host of your redis server?');
        $config['REDIS_DATABASE'] = $this->ask('What is the name of the database that Cachet should use?');
        $config['REDIS_PORT'] = $this->ask('What port should Cachet use?', 6379);

        foreach ($config as $setting => $value) {
            $this->writeEnv($setting, $value);
        }
    }
242113
public function connect(): self
    {
        if ($this->resource) {
            return $this;
        }

        $connectionWarnings = [];
        set_error_handler(function ($errno, $errstr) use (&$connectionWarnings) {
            $connectionWarnings[] = $errstr;
            return true;
        }, E_WARNING);

        $this->resource = pg_connect($this->connectionString, PGSQL_CONNECT_FORCE_NEW);

        restore_error_handler();
        if (false === $this->resource) {
            throw new exceptions\ConnectionException(
                __METHOD__ . ': ' . implode("\n", $connectionWarnings)
            );
        }
        $serverVersion = pg_parameter_status($this->resource, 'server_version');
        if (version_compare($serverVersion, '9.2.0', '<')) {
            $this->disconnect();
            throw new exceptions\ConnectionException(
                __METHOD__ . ': PostgreSQL versions earlier than 9.2 are no longer supported, '
                . 'connected server reports version ' . $serverVersion
            );
        }
        pg_set_error_verbosity($this->resource, PGSQL_ERRORS_VERBOSE);

        return $this;
    }
848040
public function connect()
    {
        $connectTimeout = 1;
        $errstr = '';
        $errno = 0;
        $stream = @stream_socket_client($this->nodeUrl, $errno, $errstr, $connectTimeout);

        if (!$stream) {
            $this->log->warning('unable to connect to '.$this->nodeUrl.': '.$errstr);
            throw new ConnectException('Unable to connect to resource '.$this->nodeUrl.'. '.$errstr, $errno);
        }

        $this->log->info('connected to '.$this->nodeUrl);
        $this->stream = $stream;

        return true;
    }
1151151
function connect() {
    if (!redis) {
      debug('createClient ' + key + ' at ' + host + ':' + port);
      redis = redisLib.createClient(port, host, redisOpts); }
  }
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']}:");
		}
	}
683401
protected function connect()
        {
                $this->_socket=@stream_socket_client(
                        $this->hostname.':'.$this->port,
                        $errorNumber,
                        $errorDescription,
                        $this->timeout ? $this->timeout : ini_get("default_socket_timeout")
                );
                if ($this->_socket)
                {
                        if($this->password!==null)
                                $this->executeCommand('AUTH',array($this->password));
                        $this->executeCommand('SELECT',array($this->database));
                }
                else
                        throw new CException('Failed to connect to redis: '.$errorDescription,(int)$errorNumber);
        }
384256
public function connect(): bool
    {
        try {
            $this->checkConnect();
            $this->log('Connect to ' . $this->connect['host']);
            $this->handler = new \PDO(
                $this->connect['type'] . ':host=' . $this->connect['host'] . ';dbname=' . $this->connect['name'],
                $this->connect['user'],
                $this->connect['pass'],
                $this->connect['options']
            );

            foreach ($this->attributes as $attribute => $value) {
                $this->handler->setAttribute($attribute, $value);
            }

            $this->ok();
        } catch (\Exception $e) {
            throw new DbException("Attempt connection to database is failed: {$e->getMessage()}");
        }
        return true;
    }
777778
public function connect(): bool
    {
        if ($this->isConnected()) {
            return true;
        }

        $errno = null;
        $errstr = null;

        // Supress PHP error, we're handling it
        $this->socket = @stream_socket_client(
            $this->getUri(),
            $errno,
            $errstr,
            $this->options['timeout_connect'],
            STREAM_CLIENT_CONNECT,
            $this->getStreamContext()
        );

        if (!$this->socket) {
            throw new \Wrench\Exception\ConnectionException(sprintf(
                'Could not connect to socket: %s (%d)',
                $errstr,
                $errno
            ));
        }

        stream_set_timeout($this->socket, $this->options['timeout_socket']);

        return ($this->connected = true);
    }