lithium\storage\cache\adapter\Memcache::_formatHostList()

protected method

Formats standard 'host:port' strings into arrays used by Memcached.

Parameters

  • mixed $host

    A host string in 'host:port' format, or an array of host strings optionally paired with relative selection weight values.

Returns

array

Returns an array of Memcached server definitions.

Source

	protected function _formatHostList($host) {
		$fromString = function($host) {
			if (strpos($host, ':')) {
				list($host, $port) = explode(':', $host);
				return array($host, (integer) $port);
			}
			return array($host, Memcache::CONN_DEFAULT_PORT);
		};

		if (is_string($host)) {
			return array($fromString($host));
		}
		$servers = array();

		while (list($server, $weight) = each($this->_config['host'])) {
			if (is_string($weight)) {
				$servers[] = $fromString($weight);
				continue;
			}
			$server = $fromString($server);
			$server[] = $weight;
			$servers[] = $server;
		}
		return $servers;
	}