Check for cache before setting up the MD parser

This commit is contained in:
Belle Aerni 2023-01-14 03:04:56 -08:00
parent b8956614b0
commit 8ed69831ee

View file

@ -26,6 +26,14 @@ class AntMarkdown
$cache = new AntCache();
$cacheKey = $cache->createCacheKey($md, 'markdown');
if ($cache->isCached($cacheKey)) {
$cachedContent = $cache->getCache($cacheKey);
if ($cachedContent !== false && !empty($cachedContent)) {
return $cachedContent;
}
}
$mdConfig = [
'embed' => [
'adapter' => new OscaroteroEmbedAdapter(),
@ -46,14 +54,6 @@ class AntMarkdown
$converter = new MarkdownConverter($environment);
if ($cache->isCached($cacheKey)) {
$cachedContent = $cache->getCache($cacheKey);
if ($cachedContent !== false && !empty($cachedContent)) {
return $cachedContent;
}
}
$result = $converter->convert($md);
$cache->setCache($cacheKey, $result);