Renames and puts in temp fix to try to find out why we are binding to old models
This commit is contained in:
@@ -47,7 +47,7 @@ namespace Umbraco.Tests.Routing
|
||||
null, // FIXME: PublishedRouter complexities...
|
||||
Mock.Of<IVariationContextAccessor>(),
|
||||
Mock.Of<IUmbracoContextFactory>(),
|
||||
new Umbraco.Web.Cache.BackgroundPublishedSnapshotServiceNotifier(
|
||||
new Umbraco.Web.Cache.BackgroundPublishedSnapshotNotifier(
|
||||
Factory.GetInstance<IPublishedModelFactory>(),
|
||||
Factory.GetInstance<IPublishedSnapshotService>(),
|
||||
Logger)
|
||||
|
||||
@@ -13,9 +13,11 @@ namespace Umbraco.Web.Cache
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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.
|
||||
/// 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.
|
||||
/// </remarks>
|
||||
public sealed class BackgroundPublishedSnapshotServiceNotifier
|
||||
public sealed class BackgroundPublishedSnapshotNotifier
|
||||
{
|
||||
private readonly IPublishedModelFactory _publishedModelFactory;
|
||||
private readonly IPublishedSnapshotService _publishedSnapshotService;
|
||||
@@ -27,7 +29,7 @@ namespace Umbraco.Web.Cache
|
||||
/// <param name="publishedModelFactory"></param>
|
||||
/// <param name="publishedSnapshotService"></param>
|
||||
/// <param name="logger"></param>
|
||||
public BackgroundPublishedSnapshotServiceNotifier(IPublishedModelFactory publishedModelFactory, IPublishedSnapshotService publishedSnapshotService, ILogger logger)
|
||||
public BackgroundPublishedSnapshotNotifier(IPublishedModelFactory publishedModelFactory, IPublishedSnapshotService publishedSnapshotService, ILogger logger)
|
||||
{
|
||||
_publishedModelFactory = publishedModelFactory;
|
||||
_publishedSnapshotService = publishedSnapshotService;
|
||||
@@ -41,7 +43,13 @@ namespace Umbraco.Web.Cache
|
||||
/// <summary>
|
||||
/// Blocks until the background operation is completed
|
||||
/// </summary>
|
||||
public void Wait() => _runner.StoppedAwaitable.GetAwaiter().GetResult(); //TODO: do we need a try/catch?
|
||||
/// <returns>Returns true if waiting was necessary</returns>
|
||||
public bool Wait()
|
||||
{
|
||||
var running = _runner.IsRunning;
|
||||
_runner.StoppedAwaitable.GetAwaiter().GetResult(); //TODO: do we need a try/catch?
|
||||
return running;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notify the <see cref="IPublishedSnapshotService"/> of content type changes
|
||||
@@ -101,6 +109,10 @@ namespace Umbraco.Web.Cache
|
||||
_publishedSnapshotService.Notify(_dataTypePayloads);
|
||||
if (_contentTypePayloads != null)
|
||||
_publishedSnapshotService.Notify(_contentTypePayloads);
|
||||
|
||||
//Thread.Sleep(10000);
|
||||
|
||||
var asdf = "";
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@ namespace Umbraco.Web.Cache
|
||||
{
|
||||
public sealed class ContentTypeCacheRefresher : PayloadCacheRefresherBase<ContentTypeCacheRefresher, ContentTypeCacheRefresher.JsonPayload>
|
||||
{
|
||||
private readonly BackgroundPublishedSnapshotServiceNotifier _backgroundModelFactory;
|
||||
private readonly BackgroundPublishedSnapshotNotifier _backgroundModelFactory;
|
||||
private readonly IContentTypeCommonRepository _contentTypeCommonRepository;
|
||||
private readonly IdkMap _idkMap;
|
||||
|
||||
public ContentTypeCacheRefresher(AppCaches appCaches, BackgroundPublishedSnapshotServiceNotifier backgroundModelFactory, IdkMap idkMap, IContentTypeCommonRepository contentTypeCommonRepository)
|
||||
public ContentTypeCacheRefresher(AppCaches appCaches, BackgroundPublishedSnapshotNotifier backgroundModelFactory, IdkMap idkMap, IContentTypeCommonRepository contentTypeCommonRepository)
|
||||
: base(appCaches)
|
||||
{
|
||||
_backgroundModelFactory = backgroundModelFactory;
|
||||
|
||||
@@ -9,10 +9,10 @@ namespace Umbraco.Web.Cache
|
||||
|
||||
public sealed class DataTypeCacheRefresher : PayloadCacheRefresherBase<DataTypeCacheRefresher, DataTypeCacheRefresher.JsonPayload>
|
||||
{
|
||||
private readonly BackgroundPublishedSnapshotServiceNotifier _backgroundModelFactory;
|
||||
private readonly BackgroundPublishedSnapshotNotifier _backgroundModelFactory;
|
||||
private readonly IdkMap _idkMap;
|
||||
|
||||
public DataTypeCacheRefresher(AppCaches appCaches, BackgroundPublishedSnapshotServiceNotifier backgroundModelFactory, IdkMap idkMap)
|
||||
public DataTypeCacheRefresher(AppCaches appCaches, BackgroundPublishedSnapshotNotifier backgroundModelFactory, IdkMap idkMap)
|
||||
: base(appCaches)
|
||||
{
|
||||
_backgroundModelFactory = backgroundModelFactory;
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace Umbraco.Web.Runtime
|
||||
// register distributed cache
|
||||
composition.RegisterUnique(f => new DistributedCache());
|
||||
|
||||
composition.RegisterUnique<BackgroundPublishedSnapshotServiceNotifier>();
|
||||
composition.RegisterUnique<BackgroundPublishedSnapshotNotifier>();
|
||||
|
||||
// replace some services
|
||||
composition.RegisterUnique<IEventMessagesFactory, DefaultEventMessagesFactory>();
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
<Compile Include="AppBuilderExtensions.cs" />
|
||||
<Compile Include="AreaRegistrationContextExtensions.cs" />
|
||||
<Compile Include="AspNetHttpContextAccessor.cs" />
|
||||
<Compile Include="Cache\BackgroundPublishedSnapshotServiceNotifier.cs" />
|
||||
<Compile Include="Cache\BackgroundPublishedSnapshotNotifier.cs" />
|
||||
<Compile Include="Cache\DistributedCacheBinder.cs" />
|
||||
<Compile Include="Cache\DistributedCacheBinderComposer.cs" />
|
||||
<Compile Include="Cache\DistributedCacheBinder_Handlers.cs" />
|
||||
|
||||
@@ -19,6 +19,7 @@ using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
using Umbraco.Web.Cache;
|
||||
using Umbraco.Web.PublishedCache.NuCache;
|
||||
|
||||
namespace Umbraco.Web
|
||||
{
|
||||
@@ -49,7 +50,7 @@ namespace Umbraco.Web
|
||||
private readonly IPublishedRouter _publishedRouter;
|
||||
private readonly IVariationContextAccessor _variationContextAccessor;
|
||||
private readonly IUmbracoContextFactory _umbracoContextFactory;
|
||||
private readonly BackgroundPublishedSnapshotServiceNotifier _backgroundNotifier;
|
||||
private readonly BackgroundPublishedSnapshotNotifier _backgroundNotifier;
|
||||
|
||||
public UmbracoInjectedModule(
|
||||
IGlobalSettings globalSettings,
|
||||
@@ -62,7 +63,7 @@ namespace Umbraco.Web
|
||||
IPublishedRouter publishedRouter,
|
||||
IVariationContextAccessor variationContextAccessor,
|
||||
IUmbracoContextFactory umbracoContextFactory,
|
||||
BackgroundPublishedSnapshotServiceNotifier backgroundNotifier)
|
||||
BackgroundPublishedSnapshotNotifier backgroundNotifier)
|
||||
{
|
||||
_combinedRouteCollection = new Lazy<RouteCollection>(CreateRouteCollection);
|
||||
|
||||
@@ -141,8 +142,19 @@ namespace Umbraco.Web
|
||||
var isRoutableAttempt = EnsureUmbracoRoutablePage(umbracoContext, httpContext);
|
||||
|
||||
// If this page is probably front-end routable, block here until the backround notifier isn't busy
|
||||
if (isRoutableAttempt)
|
||||
_backgroundNotifier.Wait();
|
||||
if (isRoutableAttempt)
|
||||
{
|
||||
//wait for the notifier to complete if it's in progress
|
||||
if (_backgroundNotifier.Wait())
|
||||
{
|
||||
// if we were waiting, we need to resync the snapshot
|
||||
// TODO: This does not belong here! BUT we cannot Resync the snapshot on the background process because there is no snapshot...
|
||||
// normally it would do that automatically but on a background thread it is null ... hrm....
|
||||
((PublishedSnapshot)_publishedSnapshotService.PublishedSnapshotAccessor.PublishedSnapshot)?.Resync();
|
||||
var done = "done";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// raise event here
|
||||
UmbracoModule.OnRouteAttempt(this, new RoutableAttemptEventArgs(isRoutableAttempt.Result, umbracoContext, httpContext));
|
||||
|
||||
Reference in New Issue
Block a user