lithium\storage\cache\adapter\Redis::_init()

protected method

Initialize the Redis connection object, connect to the Redis server and sets prefix using the scope if provided.

Returns

void

Source

	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']}:");
		}
	}