From 6dcc74bb5104236415c844e44fe716cb9a8856eb Mon Sep 17 00:00:00 2001 From: Kevin Jump Date: Wed, 13 May 2020 17:18:16 +0100 Subject: [PATCH] Ensure we clean the keyCache after a report. --- Dist/package.cmd | 4 ++-- uSync8.BackOffice/Services/uSyncService.cs | 2 +- uSync8.BackOffice/SyncHandlers/SyncHandlerBase.cs | 10 +++++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Dist/package.cmd b/Dist/package.cmd index abff4db7..3f6b18f2 100644 --- a/Dist/package.cmd +++ b/Dist/package.cmd @@ -1,7 +1,7 @@ @echo off -SET config=release -REM SET config=debug +REM SET config=release +SET config=debug @Echo Packaging for %config% nuget pack ..\uSync8.Core\uSync.Core.nuspec -build -OutputDirectory %1 -version %1 -properties "depends=%1;Configuration=%config%" diff --git a/uSync8.BackOffice/Services/uSyncService.cs b/uSync8.BackOffice/Services/uSyncService.cs index 8c7d5a01..7a3b79ec 100644 --- a/uSync8.BackOffice/Services/uSyncService.cs +++ b/uSync8.BackOffice/Services/uSyncService.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; - +using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Configuration; using Umbraco.Core.Logging; diff --git a/uSync8.BackOffice/SyncHandlers/SyncHandlerBase.cs b/uSync8.BackOffice/SyncHandlers/SyncHandlerBase.cs index 035aff11..941db10e 100644 --- a/uSync8.BackOffice/SyncHandlers/SyncHandlerBase.cs +++ b/uSync8.BackOffice/SyncHandlers/SyncHandlerBase.cs @@ -342,10 +342,10 @@ protected virtual IEnumerable CleanFolder(string cleanFile, bool re /// private IList GetFolderKeys(string folder, bool flat) { - // if it's flat, then we only need to load all the keys once per handler - var folderKey = flat == true ? 1 : folder.GetHashCode(); + // We only need to load all the keys once per handler (if all items are in a folder that key will be used). + var folderKey = folder.GetHashCode(); - var cacheKey = $"uSyncKeyList_{folderKey}_{this.Alias}"; + var cacheKey = $"keycache_{this.Alias}_{folderKey}"; return runtimeCache.GetCacheItem(cacheKey, () => { var keys = new List(); @@ -574,12 +574,16 @@ public IEnumerable Report(string folder, HandlerSettings config, Sy { var actions = new List(); + runtimeCache.ClearByKey($"keycache_{this.Alias}"); + callback?.Invoke("Checking Actions", 1, 3); actions.AddRange(ReportFolder(folder, config, callback)); callback?.Invoke("Validating Report", 2, 3); actions = ValidateReport(folder, actions); + runtimeCache.ClearByKey($"keycache_{this.Alias}"); + callback?.Invoke("Done", 3, 3); return actions; }