Cache lookup of macro by alias
This commit is contained in:
committed by
Sebastiaan Janssen
parent
0554b47864
commit
8463f1db08
@@ -11,5 +11,6 @@
|
||||
public const string TemplateFrontEndCacheKey = "template";
|
||||
|
||||
public const string MacroContentCacheKey = "macroContent_"; // used in MacroRenderers
|
||||
public const string MacroFromAliasCacheKey = "macroFromAlias_";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +99,7 @@ namespace Umbraco.Web.Cache
|
||||
return new[]
|
||||
{
|
||||
CacheKeys.MacroContentCacheKey, // macro render cache
|
||||
CacheKeys.MacroFromAliasCacheKey, // lookup macro by alias
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -197,7 +197,8 @@ namespace Umbraco.Web.Macros
|
||||
|
||||
public MacroContent Render(string macroAlias, IPublishedContent content, IDictionary<string, object> macroParams)
|
||||
{
|
||||
var m = _macroService.GetByAlias(macroAlias);
|
||||
var m = _appCaches.RuntimeCache.GetCacheItem(CacheKeys.MacroFromAliasCacheKey + macroAlias, () => _macroService.GetByAlias(macroAlias));
|
||||
|
||||
if (m == null)
|
||||
throw new InvalidOperationException("No macro found by alias " + macroAlias);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user