From 64f05e4c97b4ee7e4a00fe4366d213426fd4ddfb Mon Sep 17 00:00:00 2001 From: Stephan Date: Fri, 16 Oct 2015 17:21:44 +0200 Subject: [PATCH] U4-6797 - clear domains cache when deleting content --- src/Umbraco.Web/Cache/DistributedCacheExtensions.cs | 7 +++++++ src/Umbraco.Web/Cache/UnpublishedPageCacheRefresher.cs | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs b/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs index 84ed6f225e..fe5ba99eb5 100644 --- a/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs +++ b/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs @@ -5,6 +5,7 @@ using Umbraco.Core.Events; using Umbraco.Core.Models; using umbraco; using umbraco.cms.businesslogic.web; +using Umbraco.Core.Persistence.Repositories; namespace Umbraco.Web.Cache { @@ -400,6 +401,12 @@ namespace Umbraco.Web.Cache dc.Remove(DistributedCache.DomainCacheRefresherGuid, domain.Id); } + public static void ClearDomainCacheOnCurrentServer(this DistributedCache dc) + { + var key = RepositoryBase.GetCacheTypeKey(); + ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(key); + } + #endregion #region Language Cache diff --git a/src/Umbraco.Web/Cache/UnpublishedPageCacheRefresher.cs b/src/Umbraco.Web/Cache/UnpublishedPageCacheRefresher.cs index 47a2d73bdb..e3601188f4 100644 --- a/src/Umbraco.Web/Cache/UnpublishedPageCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/UnpublishedPageCacheRefresher.cs @@ -79,6 +79,7 @@ namespace Umbraco.Web.Cache { ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); + DistributedCache.Instance.ClearDomainCacheOnCurrentServer(); base.RefreshAll(); } @@ -87,6 +88,7 @@ namespace Umbraco.Web.Cache ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(RepositoryBase.GetCacheIdKey(id)); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); content.Instance.UpdateSortOrder(id); + DistributedCache.Instance.ClearDomainCacheOnCurrentServer(); base.Refresh(id); } @@ -94,6 +96,7 @@ namespace Umbraco.Web.Cache { ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(RepositoryBase.GetCacheIdKey(id)); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); + DistributedCache.Instance.ClearDomainCacheOnCurrentServer(); base.Remove(id); } @@ -103,6 +106,7 @@ namespace Umbraco.Web.Cache ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(RepositoryBase.GetCacheIdKey(instance.Id)); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); content.Instance.UpdateSortOrder(instance); + DistributedCache.Instance.ClearDomainCacheOnCurrentServer(); base.Refresh(instance); } @@ -110,6 +114,7 @@ namespace Umbraco.Web.Cache { ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(RepositoryBase.GetCacheIdKey(instance.Id)); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes(); + DistributedCache.Instance.ClearDomainCacheOnCurrentServer(); base.Remove(instance); } @@ -127,6 +132,8 @@ namespace Umbraco.Web.Cache content.Instance.UpdateSortOrder(payload.Id); } + DistributedCache.Instance.ClearDomainCacheOnCurrentServer(); + OnCacheUpdated(Instance, new CacheRefresherEventArgs(jsonPayload, MessageType.RefreshByJson)); }