concrete/src/Session/SessionFactory.php
private function getRedisInstance(array $servers)
    {
        if (count($servers) == 1) {
            // If we only have one server in our array then we just reconnect to it
            $server = $servers[0];
            $redis = $this->app->make(Redis::class);

            if (isset($server['socket']) && $server['socket']) {
                $redis->connect($server['socket']);
            } else {
                $host = array_get($server, 'host', '');
                $port = array_get($server, 'port', 6379);
                $ttl = array_get($server, 'ttl', 0.5);
                // Check for both server/host - fallback due to cache using server
                $host = !empty($host) ? $host : array_get($server, 'server', '127.0.0.1');

                $redis->connect($host, $port, $ttl);
            }

            // Authorisation is handled by just a password
            if (isset($server['password'])) {
                $redis->auth($server['password']);
            }
        } else {
            $serverArray = [];
            $ttl = 0.5;
            foreach ($this->getRedisServers($servers) as $server) {
                $serverString = $server['server'];
                if (isset($server['port'])) {
                    $serverString .= ':' . $server['port'];
                }
                // We can only use one ttl for connection timeout so use the last set ttl
                // isset allows for 0 - unlimited
                if (!isset($server['ttl'])) {
                    $ttl = $server['ttl'];
                }

                $serverArray[] = $serverString;
            }
            $redis = $this->app->make(RedisArray::class, [$serverArray, ['connect_timeout' => $ttl]]);
        }

        return $redis;
    }
private function getRedisInstance(array $servers)
    {
        if (count($servers) == 1) {
            // If we only have one server in our array then we just reconnect to it
            $server = $servers[0];
            $redis = $this->app->make(Redis::class);

            if (isset($server['socket']) && $server['socket']) {
                $redis->connect($server['socket']);
            } else {
                $host = array_get($server, 'host', '');
                $port = array_get($server, 'port', 6379);
                $ttl = array_get($server, 'ttl', 0.5);
                // Check for both server/host - fallback due to cache using server
                $host = !empty($host) ? $host : array_get($server, 'server', '127.0.0.1');

                $redis->connect($host, $port, $ttl);
            }

            // Authorisation is handled by just a password
            if (isset($server['password'])) {
                $redis->auth($server['password']);
            }
        } else {
            $serverArray = [];
            $ttl = 0.5;
            foreach ($this->getRedisServers($servers) as $server) {
                $serverString = $server['server'];
                if (isset($server['port'])) {
                    $serverString .= ':' . $server['port'];
                }
                // We can only use one ttl for connection timeout so use the last set ttl
                // isset allows for 0 - unlimited
                if (!isset($server['ttl'])) {
                    $ttl = $server['ttl'];
                }

                $serverArray[] = $serverString;
            }
            $redis = $this->app->make(RedisArray::class, [$serverArray, ['connect_timeout' => $ttl]]);
        }

        return $redis;
    }
private function getRedisInstance ( array $ servers ) { if ( count ( $ servers ) == 1 ) { // If we only have one server in our array then we just reconnect to it $ server = $ servers [ 0 ] ; $ redis = $ this -> app -> make ( Redis :: class ) ; if ( isset ( $ server [ 'socket' ] ) && $ server [ 'socket' ] ) { $ redis -> connect ( $ server [ 'socket' ] ) ; } else { $ host = array_get ( $ server , 'host' , '' ) ; $ port = array_get ( $ server , 'port' , 6379 ) ; $ ttl = array_get ( $ server , 'ttl' , 0.5 ) ; // Check for both server/host - fallback due to cache using server $ host = ! empty ( $ host ) ? $ host : array_get ( $ server , 'server' , '127.0.0.1' ) ; $ redis -> connect ( $ host , $ port , $ ttl ) ; } // Authorisation is handled by just a password if ( isset ( $ server [ 'password' ] ) ) { $ redis -> auth ( $ server [ 'password' ] ) ; } } else { $ serverArray = [ ] ; $ ttl = 0.5 ; foreach ( $ this -> getRedisServers ( $ servers ) as $ server ) { $ serverString = $ server [ 'server' ] ; if ( isset ( $ server [ 'port' ] ) ) { $ serverString .= ':' . $ server [ 'port' ] ; } // We can only use one ttl for connection timeout so use the last set ttl // isset allows for 0 - unlimited if ( ! isset ( $ server [ 'ttl' ] ) ) { $ ttl = $ server [ 'ttl' ] ; } $ serverArray [ ] = $ serverString ; } $ redis = $ this -> app -> make ( RedisArray :: class , [ $ serverArray , [ 'connect_timeout' => $ ttl ] ] ) ; } return $ redis ; }
Decides whether to return a Redis Instance or RedisArray Instance depending on the number of servers passed to it.

@param array $servers The `concrete.session.servers` or `concrete.session.redis.servers` config item

@return \Redis | \RedisArray
Decides whether to return a Redis Instance or RedisArray Instance depending on the number of servers passed to it .