From ffeeb4f7d421ef631f5eb7030fbadf18be05d04d Mon Sep 17 00:00:00 2001 From: Stephan Date: Wed, 8 Jun 2016 14:19:15 +0200 Subject: [PATCH] Cleanup - more distributed cache cleanup --- .../Services/Changes/DomainChangeTypes.cs | 10 ++++++ src/Umbraco.Core/Umbraco.Core.csproj | 1 + src/Umbraco.Tests/Cache/RefresherTests.cs | 2 +- .../Cache/ContentCacheRefresher.cs | 3 -- .../Cache/DistributedCacheExtensions.cs | 35 ++----------------- src/Umbraco.Web/Cache/DomainCacheRefresher.cs | 13 ++----- .../PublishedCache/NuCache/FacadeService.cs | 6 ++-- src/Umbraco.Web/WebBootManager.cs | 2 +- 8 files changed, 22 insertions(+), 50 deletions(-) create mode 100644 src/Umbraco.Core/Services/Changes/DomainChangeTypes.cs diff --git a/src/Umbraco.Core/Services/Changes/DomainChangeTypes.cs b/src/Umbraco.Core/Services/Changes/DomainChangeTypes.cs new file mode 100644 index 0000000000..17a8da6230 --- /dev/null +++ b/src/Umbraco.Core/Services/Changes/DomainChangeTypes.cs @@ -0,0 +1,10 @@ +namespace Umbraco.Core.Services.Changes +{ + public enum DomainChangeTypes : byte + { + None = 0, + RefreshAll = 1, + Refresh = 2, + Remove = 3 + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 7c29e76d25..beecf54ddc 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -448,6 +448,7 @@ + diff --git a/src/Umbraco.Tests/Cache/RefresherTests.cs b/src/Umbraco.Tests/Cache/RefresherTests.cs index 3b7327d8c9..b1d0ad7b1a 100644 --- a/src/Umbraco.Tests/Cache/RefresherTests.cs +++ b/src/Umbraco.Tests/Cache/RefresherTests.cs @@ -54,7 +54,7 @@ namespace Umbraco.Tests.Cache [Test] public void DomainCacheRefresherCanDeserializeJsonPayload() { - var source = new[] { new DomainCacheRefresher.JsonPayload(1234, DomainCacheRefresher.ChangeTypes.None) }; + var source = new[] { new DomainCacheRefresher.JsonPayload(1234, DomainChangeTypes.None) }; var json = JsonConvert.SerializeObject(source); var payload = JsonConvert.DeserializeObject(json); Assert.AreEqual(source[0].Id, payload[0].Id); diff --git a/src/Umbraco.Web/Cache/ContentCacheRefresher.cs b/src/Umbraco.Web/Cache/ContentCacheRefresher.cs index de8b7dcace..d2a6f97018 100644 --- a/src/Umbraco.Web/Cache/ContentCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/ContentCacheRefresher.cs @@ -130,9 +130,6 @@ namespace Umbraco.Web.Cache MacroCacheRefresher.ClearMacroContentCache(cacheHelper); // just the content ClearXsltCache(); - // fixme which? - cacheHelper.RuntimeCache.ClearCacheObjectTypes(); - cacheHelper.RuntimeCache.ClearCacheObjectTypes(); cacheHelper.IsolatedRuntimeCache.ClearCache(); cacheHelper.IsolatedRuntimeCache.ClearCache(); } diff --git a/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs b/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs index a95f9edbc7..061fc57775 100644 --- a/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs +++ b/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs @@ -242,15 +242,6 @@ namespace Umbraco.Web.Cache #region MacroCache - // fixme! - /* - public static void ClearAllMacroCacheOnCurrentServer(this DistributedCache dc) - { - var macroRefresher = CacheRefreshersResolver.Current.GetById(MacroCacheRefresher.UniqueId); - macroRefresher.RefreshAll(); - } - */ - public static void RefreshMacroCache(this DistributedCache dc, IMacro macro) { if (macro == null) return; @@ -316,32 +307,23 @@ namespace Umbraco.Web.Cache public static void RefreshDomainCache(this DistributedCache dc, IDomain domain) { if (domain == null) return; - var payloads = new[] { new DomainCacheRefresher.JsonPayload(domain.Id, DomainCacheRefresher.ChangeTypes.Refresh) }; + var payloads = new[] { new DomainCacheRefresher.JsonPayload(domain.Id, DomainChangeTypes.Refresh) }; dc.RefreshByPayload(DomainCacheRefresher.UniqueId, payloads); } public static void RemoveDomainCache(this DistributedCache dc, IDomain domain) { if (domain == null) return; - var payloads = new[] { new DomainCacheRefresher.JsonPayload(domain.Id, DomainCacheRefresher.ChangeTypes.Remove) }; + var payloads = new[] { new DomainCacheRefresher.JsonPayload(domain.Id, DomainChangeTypes.Remove) }; dc.RefreshByPayload(DomainCacheRefresher.UniqueId, payloads); } public static void RefreshAllDomainCache(this DistributedCache dc) { - var payloads = new[] { new DomainCacheRefresher.JsonPayload(0, DomainCacheRefresher.ChangeTypes.RefreshAll) }; + var payloads = new[] { new DomainCacheRefresher.JsonPayload(0, DomainChangeTypes.RefreshAll) }; dc.RefreshByPayload(DomainCacheRefresher.UniqueId, payloads); } - // fixme? - /* - public static void ClearDomainCacheOnCurrentServer(this DistributedCache dc) - { - var domainRefresher = CacheRefreshersResolver.Current.GetById(DomainCacheRefresher.UniqueId); - domainRefresher.RefreshAll(); - } - */ - #endregion #region Language Cache @@ -371,16 +353,5 @@ namespace Umbraco.Web.Cache } #endregion - - #region Xslt Cache - - // fixme? - public static void ClearXsltCacheOnCurrentServer(this DistributedCache dc, CacheHelper cacheHelper) - { - if (UmbracoConfig.For.UmbracoSettings().Content.UmbracoLibraryCacheDuration <= 0) return; - cacheHelper.RuntimeCache.ClearCacheObjectTypes("MS.Internal.Xml.XPath.XPathSelectionIterator"); - } - - #endregion } } \ No newline at end of file diff --git a/src/Umbraco.Web/Cache/DomainCacheRefresher.cs b/src/Umbraco.Web/Cache/DomainCacheRefresher.cs index 89d2ec2266..7979bd561f 100644 --- a/src/Umbraco.Web/Cache/DomainCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/DomainCacheRefresher.cs @@ -1,6 +1,7 @@ using System; using Umbraco.Core.Cache; using Umbraco.Core.Models; +using Umbraco.Core.Services.Changes; using Umbraco.Web.PublishedCache; namespace Umbraco.Web.Cache @@ -72,7 +73,7 @@ namespace Umbraco.Web.Cache public class JsonPayload { - public JsonPayload(int id, ChangeTypes changeType) + public JsonPayload(int id, DomainChangeTypes changeType) { Id = id; ChangeType = changeType; @@ -80,15 +81,7 @@ namespace Umbraco.Web.Cache public int Id { get; } - public ChangeTypes ChangeType { get; } - } - - public enum ChangeTypes : byte // fixme should NOT be here !? - { - None = 0, - RefreshAll = 1, - Refresh = 2, - Remove = 3 + public DomainChangeTypes ChangeType { get; } } #endregion diff --git a/src/Umbraco.Web/PublishedCache/NuCache/FacadeService.cs b/src/Umbraco.Web/PublishedCache/NuCache/FacadeService.cs index ba992c31d0..056e6c3236 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/FacadeService.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/FacadeService.cs @@ -753,7 +753,7 @@ namespace Umbraco.Web.PublishedCache.NuCache { switch (payload.ChangeType) { - case DomainCacheRefresher.ChangeTypes.RefreshAll: + case DomainChangeTypes.RefreshAll: var domainService = _serviceContext.DomainService as DomainService; if (domainService == null) throw new Exception("oops"); using (var uow = _uowProvider.CreateUnitOfWork()) @@ -763,10 +763,10 @@ namespace Umbraco.Web.PublishedCache.NuCache uow.Complete(); } break; - case DomainCacheRefresher.ChangeTypes.Remove: + case DomainChangeTypes.Remove: _domainStore.Clear(payload.Id); break; - case DomainCacheRefresher.ChangeTypes.Refresh: + case DomainChangeTypes.Refresh: var domain = _serviceContext.DomainService.GetById(payload.Id); if (domain == null) continue; if (domain.RootContentId.HasValue == false) continue; // anomaly diff --git a/src/Umbraco.Web/WebBootManager.cs b/src/Umbraco.Web/WebBootManager.cs index d705fffb5a..aeb82abfab 100644 --- a/src/Umbraco.Web/WebBootManager.cs +++ b/src/Umbraco.Web/WebBootManager.cs @@ -447,7 +447,7 @@ namespace Umbraco.Web // note: refresh all content & media caches does refresh content types too IFacadeService svc = FacadeServiceResolver.Current.Service; bool ignored1, ignored2; - svc.Notify(new[] { new DomainCacheRefresher.JsonPayload(0, DomainCacheRefresher.ChangeTypes.RefreshAll) }); + svc.Notify(new[] { new DomainCacheRefresher.JsonPayload(0, DomainChangeTypes.RefreshAll) }); svc.Notify(new[] { new ContentCacheRefresher.JsonPayload(0, TreeChangeTypes.RefreshAll) }, out ignored1, out ignored2); svc.Notify(new[] { new MediaCacheRefresher.JsonPayload(0, TreeChangeTypes.RefreshAll) }, out ignored1); },