Web.PublishedCache - refactor contextual caches & inner caches management

This commit is contained in:
Stephan
2013-03-31 18:44:29 -02:00
parent 70ad3edc1f
commit b89951dd11
5 changed files with 123 additions and 47 deletions

View File

@@ -14,12 +14,14 @@ namespace Umbraco.Web.PublishedCache
internal abstract class ContextualPublishedCache
{
protected readonly UmbracoContext UmbracoContext;
private readonly IPublishedCache _cache;
protected ContextualPublishedCache(UmbracoContext umbracoContext, IPublishedCache cache)
/// <summary>
/// Initializes a new instance of the <see cref="ContextualPublishedCache"/> with a context.
/// </summary>
/// <param name="umbracoContext">The context.</param>
protected ContextualPublishedCache(UmbracoContext umbracoContext)
{
UmbracoContext = umbracoContext;
_cache = cache;
}
/// <summary>
@@ -27,19 +29,13 @@ namespace Umbraco.Web.PublishedCache
/// </summary>
/// <param name="contentId">The content unique identifier.</param>
/// <returns>The content, or null.</returns>
public virtual IPublishedContent GetById(int contentId)
{
return _cache.GetById(UmbracoContext, contentId);
}
public abstract IPublishedContent GetById(int contentId);
/// <summary>
/// Gets contents at root.
/// </summary>
/// <returns>The contents.</returns>
public virtual IEnumerable<IPublishedContent> GetAtRoot()
{
return _cache.GetAtRoot(UmbracoContext);
}
public abstract IEnumerable<IPublishedContent> GetAtRoot();
/// <summary>
/// Gets a content resulting from an XPath query.
@@ -52,10 +48,7 @@ namespace Umbraco.Web.PublishedCache
/// value which itself is <c>null</c>, then variables are ignored.</para>
/// <para>The XPath expression should reference variables as <c>$var</c>.</para>
/// </remarks>
public virtual IPublishedContent GetSingleByXPath(string xpath, params XPathVariable[] vars)
{
return _cache.GetSingleByXPath(UmbracoContext, xpath, vars);
}
public abstract IPublishedContent GetSingleByXPath(string xpath, params XPathVariable[] vars);
/// <summary>
/// Gets contents resulting from an XPath query.
@@ -68,27 +61,18 @@ namespace Umbraco.Web.PublishedCache
/// value which itself is <c>null</c>, then variables are ignored.</para>
/// <para>The XPath expression should reference variables as <c>$var</c>.</para>
/// </remarks>
public virtual IEnumerable<IPublishedContent> GetByXPath(string xpath, params XPathVariable[] vars)
{
return _cache.GetByXPath(UmbracoContext, xpath, vars);
}
public abstract IEnumerable<IPublishedContent> GetByXPath(string xpath, params XPathVariable[] vars);
/// <summary>
/// Gets an XPath navigator that can be used to navigate contents.
/// </summary>
/// <returns>The XPath navigator.</returns>
public virtual XPathNavigator GetXPathNavigator()
{
return _cache.GetXPathNavigator(UmbracoContext);
}
public abstract XPathNavigator GetXPathNavigator();
/// <summary>
/// Gets a value indicating whether the underlying non-contextual cache contains published content.
/// </summary>
/// <returns>A value indicating whether the underlying non-contextual cache contains published content.</returns>
public virtual bool HasContent()
{
return _cache.HasContent();
}
public abstract bool HasContent();
}
}