protected function buildLinkWithInMemoryCache($pageUid, array $arguments)
    {
        $values = [];
        $structure = $arguments;
        $this->getSubstitution($structure, $values);
        $hash = md5($pageUid . json_encode($structure));
        if (isset(self::$preCompiledLinks[$hash])) {
            self::$hitCount++;
            $uriCacheTemplate = self::$preCompiledLinks[$hash];
        } else {
            self::$missCount++;
            $this->uriBuilder->setTargetPageUid($pageUid);
            $uriCacheTemplate = $this->uriBuilder->setArguments($structure)->setUseCacheHash(false)->build();

            // even if we call build with disabled cHash in TYPO3 9 a cHash will be generated when site management is active
            // to prevent wrong cHashes we remove the cHash here from the cached uri template.
            // @todo: This can be removed when https://forge.typo3.org/issues/87120 is resolved and we can ship a proper configuration
            $urlHelper = GeneralUtility::makeInstance(UrlHelper::class, $uriCacheTemplate);
            $urlHelper->removeQueryParameter('cHash');
            $uriCacheTemplate = $urlHelper->getUrl();

            self::$preCompiledLinks[$hash] = $uriCacheTemplate;
        }

        $keys = array_map(function($value) {
            return urlencode($value);
        }, array_keys($values));
        $values = array_map(function($value) {
            return urlencode($value);
        }, $values);
        $uri = str_replace($keys, $values, $uriCacheTemplate);
        return $uri;
    }