lithium\storage\cache\adapter\Memcache::_formatHostList PHP Method

_formatHostList() protected method

Formats standard 'host:port' strings into arrays used by Memcached.
protected _formatHostList ( mixed $host ) : array
$host mixed A host string in `'host:port'` format, or an array of host strings optionally paired with relative selection weight values.
return array Returns an array of `Memcached` server definitions.
    protected function _formatHostList($host)
    {
        $fromString = function ($host) {
            if (strpos($host, ':')) {
                list($host, $port) = explode(':', $host);
                return array($host, (int) $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;
    }