Merge pull request #143 from IDisposable/patch-1

Added contextualKeyBuilder optional argument to allow the key used for cachin...
This commit is contained in:
Shandem
2013-12-18 17:32:26 -08:00

View File

@@ -82,7 +82,8 @@ namespace Umbraco.Web
int cachedSeconds,
bool cacheByPage = false,
bool cacheByMember = false,
ViewDataDictionary viewData = null)
ViewDataDictionary viewData = null,
Func<object, ViewDataDictionary, string> contextualKeyBuilder = null)
{
var cacheKey = new StringBuilder(partialViewName);
if (cacheByPage)
@@ -97,7 +98,12 @@ namespace Umbraco.Web
{
var currentMember = Member.GetCurrentMember();
cacheKey.AppendFormat("m{0}-", currentMember == null ? 0 : currentMember.Id);
}
}
if (contextualKeyBuilder != null)
{
var contextualKey = contextualKeyBuilder(model, viewData);
cacheKey.Append("c{0}-", contextualKey);
}
return ApplicationContext.Current.ApplicationCache.CachedPartialView(htmlHelper, partialViewName, model, cachedSeconds, cacheKey.ToString(), viewData);
}
@@ -813,4 +819,4 @@ namespace Umbraco.Web
#endregion
}
}
}