public function build()
    {
        $this->map = array(
            'default' => null,
            'hosts' => array()
        );

        if (!DB::is_active() ||
            !DB::get_schema()->hasTable(Site::config()->table_name)) {
            return;
        }

        $sites     = Site::get();

        /**
         * 	After duplicating a site, the duplicate contains the same host and causes a 404 during resolution.
         * 	IMPORTANT, this is required to prevent the site from going down.
         * 	---
         */
        $sites = $sites->sort(array(
            'ID' => 'DESC'
        ));

        // ---

        foreach ($sites as $site) {
            if ($site->IsDefault) {
                $this->map['default'] = $site->ID;
            }

            $hosts = array($site->Host);
            $hosts = array_merge($hosts, (array) $site->HostAliases->getValue());

            foreach ($hosts as $host) {
                if (!$host) {
                    continue;
                }
                if ($site->Scheme != 'https') {
                    $this->map['hosts']["http://$host"] = $site->ID;
                }

                if ($site->Scheme != 'http') {
                    $this->map['hosts']["https://$host"] = $site->ID;
                }
            }
        }

        $this->cache->set(self::CACHE_KEY, $this->map);
    }