Fixes: U4-3193 Partial view cache needs to invalidate based on cache refreshers

This commit is contained in:
Shannon
2013-10-18 16:13:41 +11:00
parent a87e699f8d
commit d20ea58467
6 changed files with 11 additions and 28 deletions

View File

@@ -8,6 +8,7 @@ using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Tests.PartialTrust;
using Umbraco.Web;
using Umbraco.Web.Cache;
using UmbracoExamine;
using umbraco;
using umbraco.presentation;
@@ -67,7 +68,7 @@ namespace Umbraco.Tests
var t6 = TypeHelper.GetLowestBaseType(typeof (IApplicationEventHandler),
typeof (LegacyScheduledTasks),
typeof(CacheHelperExtensions.CacheHelperApplicationEventListener));
typeof(CacheRefresherEventHandler));
Assert.IsTrue(t6.Success);
Assert.AreEqual(typeof(IApplicationEventHandler), t6.Result);

View File

@@ -111,6 +111,8 @@ namespace Umbraco.Web.Cache
{
if (payloads == null) return;
ApplicationContext.Current.ApplicationCache.ClearPartialViewCache();
payloads.ForEach(payload =>
{
foreach (var idPart in payload.Path.Split(','))

View File

@@ -44,6 +44,8 @@ namespace Umbraco.Web.Cache
private void ClearCache(int id)
{
ApplicationContext.Current.ApplicationCache.ClearPartialViewCache();
ApplicationContext.Current.ApplicationCache.
ClearCacheByKeySearch(string.Format("{0}_{1}", CacheKeys.MemberLibraryCacheKey, id));
ApplicationContext.Current.ApplicationCache.

View File

@@ -1,4 +1,5 @@
using System;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Models;
using Umbraco.Core.Sync;
@@ -60,6 +61,7 @@ namespace Umbraco.Web.Cache
/// <param name="id">The id.</param>
public override void Refresh(int id)
{
ApplicationContext.Current.ApplicationCache.ClearPartialViewCache();
content.Instance.UpdateDocumentCache(id);
DistributedCache.Instance.ClearAllMacroCacheOnCurrentServer();
DistributedCache.Instance.ClearXsltCacheOnCurrentServer();
@@ -72,6 +74,7 @@ namespace Umbraco.Web.Cache
/// <param name="id">The id.</param>
public override void Remove(int id)
{
ApplicationContext.Current.ApplicationCache.ClearPartialViewCache();
content.Instance.ClearDocumentCache(id);
DistributedCache.Instance.ClearAllMacroCacheOnCurrentServer();
DistributedCache.Instance.ClearXsltCacheOnCurrentServer();
@@ -80,6 +83,7 @@ namespace Umbraco.Web.Cache
public override void Refresh(IContent instance)
{
ApplicationContext.Current.ApplicationCache.ClearPartialViewCache();
content.Instance.UpdateDocumentCache(new Document(instance));
DistributedCache.Instance.ClearAllMacroCacheOnCurrentServer();
DistributedCache.Instance.ClearXsltCacheOnCurrentServer();
@@ -88,6 +92,7 @@ namespace Umbraco.Web.Cache
public override void Remove(IContent instance)
{
ApplicationContext.Current.ApplicationCache.ClearPartialViewCache();
content.Instance.ClearDocumentCache(new Document(instance));
DistributedCache.Instance.ClearAllMacroCacheOnCurrentServer();
DistributedCache.Instance.ClearXsltCacheOnCurrentServer();

View File

@@ -18,32 +18,6 @@ namespace Umbraco.Web
/// </summary>
internal static class CacheHelperExtensions
{
/// <summary>
/// Application event handler to bind to events to clear the cache for the cache helper extensions
/// </summary>
internal sealed class CacheHelperApplicationEventListener : ApplicationEventHandler
{
protected override void ApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
if (applicationContext != null)
{
//bind to events to clear the cache, after publish, after media save and after member save
Document.AfterPublish
+= (sender, args) =>
applicationContext.ApplicationCache.ClearPartialViewCache();
global::umbraco.cms.businesslogic.media.Media.AfterSave
+= (sender, args) =>
applicationContext.ApplicationCache.ClearPartialViewCache();
global::umbraco.cms.businesslogic.member.Member.AfterSave
+= (sender, args) =>
applicationContext.ApplicationCache.ClearPartialViewCache();
}
}
}
public const string PartialViewCacheKey = "Umbraco.Web.PartialViewCacheKey";

View File

@@ -116,7 +116,6 @@ namespace Umbraco.Web
protected override void InitializeApplicationEventsResolver()
{
base.InitializeApplicationEventsResolver();
ApplicationEventsResolver.Current.AddType<CacheHelperExtensions.CacheHelperApplicationEventListener>();
ApplicationEventsResolver.Current.AddType<LegacyScheduledTasks>();
//We need to remove these types because we've obsoleted them and we don't want them executing:
ApplicationEventsResolver.Current.RemoveType<global::umbraco.LibraryCacheRefresher>();