diff --git a/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs b/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs index 060ce549dd..e95fdfc87c 100644 --- a/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs +++ b/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs @@ -42,11 +42,6 @@ namespace Umbraco.Tests.Routing logger, null, // FIXME: PublishedRouter complexities... Mock.Of(), - Mock.Of(), - new Umbraco.Web.Cache.BackgroundPublishedSnapshotNotifier( - Factory.GetInstance(), - Factory.GetInstance(), - Logger), new RoutableDocumentFilter(globalSettings) ); diff --git a/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs b/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs index 7ee75b1d9c..9cc2b97445 100644 --- a/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs +++ b/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs @@ -91,8 +91,6 @@ namespace Umbraco.Tests.TestHelpers factory.ResetForTests(); return factory; }); - - Composition.RegisterUnique(); } [OneTimeTearDown] diff --git a/src/Umbraco.Web/Cache/BackgroundPublishedSnapshotNotifier.cs b/src/Umbraco.Web/Cache/BackgroundPublishedSnapshotNotifier.cs deleted file mode 100644 index e2b3c07cea..0000000000 --- a/src/Umbraco.Web/Cache/BackgroundPublishedSnapshotNotifier.cs +++ /dev/null @@ -1,120 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; -using Umbraco.Core; -using Umbraco.Core.Models.PublishedContent; -using Umbraco.Core.Logging; -using Umbraco.Web.PublishedCache; -using Umbraco.Web.Scheduling; - -namespace Umbraco.Web.Cache -{ - /// - /// Used to notify the of changes using a background thread - /// - /// - /// When in Pure Live mode, the models need to be rebuilt before the IPublishedSnapshotService is notified which can result in performance penalties so - /// this performs these actions on a background thread so the user isn't waiting for the rebuilding to occur on a UI thread. - /// When using this, even when not in Pure Live mode, it still means that the cache is notified on a background thread. - /// In order to wait for the processing to complete, this class has a Wait() method which will block until the processing is finished. - /// - public sealed class BackgroundPublishedSnapshotNotifier - { - private readonly IPublishedModelFactory _publishedModelFactory; - private readonly IPublishedSnapshotService _publishedSnapshotService; - private readonly BackgroundTaskRunner _runner; - - /// - /// Constructor - /// - /// - /// - /// - public BackgroundPublishedSnapshotNotifier(IPublishedModelFactory publishedModelFactory, IPublishedSnapshotService publishedSnapshotService, ILogger logger) - { - _publishedModelFactory = publishedModelFactory; - _publishedSnapshotService = publishedSnapshotService; - _runner = new BackgroundTaskRunner("RebuildModelsAndCache", logger); - } - - /// - /// Blocks until the background operation is completed - /// - /// Returns true if waiting was necessary - public bool Wait() - { - var running = _runner.IsRunning; - _runner.StoppedAwaitable.GetAwaiter().GetResult(); //TODO: do we need a try/catch? - return running; - } - - /// - /// Notify the of content type changes - /// - /// - public void NotifyWithSafeLiveFactory(ContentTypeCacheRefresher.JsonPayload[] payloads) - { - _runner.TryAdd(new RebuildModelsAndCacheTask(payloads, _publishedModelFactory, _publishedSnapshotService)); - } - - /// - /// Notify the of data type changes - /// - /// - public void NotifyWithSafeLiveFactory(DataTypeCacheRefresher.JsonPayload[] payloads) - { - _runner.TryAdd(new RebuildModelsAndCacheTask(payloads, _publishedModelFactory, _publishedSnapshotService)); - } - - /// - /// A simple background task that notifies the of changes - /// - private class RebuildModelsAndCacheTask : IBackgroundTask - { - private readonly DataTypeCacheRefresher.JsonPayload[] _dataTypePayloads; - private readonly ContentTypeCacheRefresher.JsonPayload[] _contentTypePayloads; - private readonly IPublishedModelFactory _publishedModelFactory; - private readonly IPublishedSnapshotService _publishedSnapshotService; - - private RebuildModelsAndCacheTask(IPublishedModelFactory publishedModelFactory, IPublishedSnapshotService publishedSnapshotService) - { - _publishedModelFactory = publishedModelFactory; - _publishedSnapshotService = publishedSnapshotService; - } - - public RebuildModelsAndCacheTask(DataTypeCacheRefresher.JsonPayload[] payloads, IPublishedModelFactory publishedModelFactory, IPublishedSnapshotService publishedSnapshotService) - : this(publishedModelFactory, publishedSnapshotService) - { - _dataTypePayloads = payloads; - } - - public RebuildModelsAndCacheTask(ContentTypeCacheRefresher.JsonPayload[] payloads, IPublishedModelFactory publishedModelFactory, IPublishedSnapshotService publishedSnapshotService) - : this(publishedModelFactory, publishedSnapshotService) - { - _contentTypePayloads = payloads; - } - - public void Run() - { - // we have to refresh models before we notify the published snapshot - // service of changes, else factories may try to rebuild models while - // we are using the database to load content into caches - - _publishedModelFactory.WithSafeLiveFactory(() => - { - if (_dataTypePayloads != null) - _publishedSnapshotService.Notify(_dataTypePayloads); - if (_contentTypePayloads != null) - _publishedSnapshotService.Notify(_contentTypePayloads); - }); - } - - public Task RunAsync(CancellationToken token) => throw new System.NotImplementedException(); - - public bool IsAsync => false; - - public void Dispose() - { - } - } - } -} diff --git a/src/Umbraco.Web/Runtime/WebInitialComposer.cs b/src/Umbraco.Web/Runtime/WebInitialComposer.cs index 9e3413ba4d..87c0f46fba 100644 --- a/src/Umbraco.Web/Runtime/WebInitialComposer.cs +++ b/src/Umbraco.Web/Runtime/WebInitialComposer.cs @@ -125,7 +125,6 @@ namespace Umbraco.Web.Runtime // register distributed cache composition.RegisterUnique(f => new DistributedCache()); - composition.RegisterUnique(); composition.RegisterUnique(); // replace some services diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 1b8bc1b512..c6945a6b15 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -115,7 +115,6 @@ - diff --git a/src/Umbraco.Web/UmbracoInjectedModule.cs b/src/Umbraco.Web/UmbracoInjectedModule.cs index 69af843644..75251abaeb 100644 --- a/src/Umbraco.Web/UmbracoInjectedModule.cs +++ b/src/Umbraco.Web/UmbracoInjectedModule.cs @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.IO; using System.Web; using System.Web.Routing; using Umbraco.Core; @@ -12,8 +11,6 @@ using Umbraco.Web.Routing; using Umbraco.Core.Exceptions; using Umbraco.Core.Security; using Umbraco.Web.Composing; -using Umbraco.Web.Cache; -using Umbraco.Core.Models.PublishedContent; namespace Umbraco.Web { @@ -39,8 +36,6 @@ namespace Umbraco.Web private readonly ILogger _logger; private readonly IPublishedRouter _publishedRouter; private readonly IUmbracoContextFactory _umbracoContextFactory; - private readonly IPublishedModelFactory _publishedModelFactory; - private readonly BackgroundPublishedSnapshotNotifier _backgroundNotifier; private readonly RoutableDocumentFilter _routableDocumentLookup; public UmbracoInjectedModule( @@ -49,8 +44,6 @@ namespace Umbraco.Web ILogger logger, IPublishedRouter publishedRouter, IUmbracoContextFactory umbracoContextFactory, - IPublishedModelFactory publishedModelFactory, - BackgroundPublishedSnapshotNotifier backgroundNotifier, RoutableDocumentFilter routableDocumentLookup) { _globalSettings = globalSettings; @@ -58,8 +51,6 @@ namespace Umbraco.Web _logger = logger; _publishedRouter = publishedRouter; _umbracoContextFactory = umbracoContextFactory; - _publishedModelFactory = publishedModelFactory; - _backgroundNotifier = backgroundNotifier; _routableDocumentLookup = routableDocumentLookup; }