• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/data/configurator/memcachedconnectionconfigurator.php
  • Класс: BitrixMainDataConfiguratorMemcachedConnectionConfigurator
  • Вызов: MemcachedConnectionConfigurator::addServers
protected function addServers(array $config): MemcachedConnectionConfigurator
{
	$servers = $config['servers'] ?? [];

	if (isset($config['host'], $config['port']))
	{
		array_unshift($servers, [
			'host' => $config['host'],
			'port' => $config['port'],
		]);
	}

	foreach ($servers as $server)
	{
		if (!isset($server['weight']) || $server['weight'] <= 0)
		{
			$server['weight'] = 1;
		}

		$this->servers[] = [
			$server['host'] ?? 'localhost',
			$server['port'] ?? '11211',
			$server['weight']
		];
	}

	return $this;
}