Merge pull request #9859 from nzdev/v8/bugfix/fix-cold-boot
Reduce cold boot times by loading content and media only once on cold boot
This commit is contained in:
17
src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs
Executable file → Normal file
17
src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs
Executable file → Normal file
@@ -24,6 +24,7 @@ using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Services.Changes;
|
||||
using Umbraco.Core.Services.Implement;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Core.Sync;
|
||||
using Umbraco.Web.Cache;
|
||||
using Umbraco.Web.Install;
|
||||
using Umbraco.Web.PublishedCache.NuCache.DataSource;
|
||||
@@ -63,6 +64,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
private bool _localContentDbExists;
|
||||
private bool _localMediaDbExists;
|
||||
|
||||
private readonly ISyncBootStateAccessor _syncBootStateAccessor;
|
||||
|
||||
// define constant - determines whether to use cache when previewing
|
||||
// to store eg routes, property converted values, anything - caching
|
||||
// means faster execution, but uses memory - not sure if we want it
|
||||
@@ -81,7 +84,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
IDataSource dataSource, IGlobalSettings globalSettings,
|
||||
IEntityXmlSerializer entitySerializer,
|
||||
IPublishedModelFactory publishedModelFactory,
|
||||
UrlSegmentProviderCollection urlSegmentProviders)
|
||||
UrlSegmentProviderCollection urlSegmentProviders,
|
||||
ISyncBootStateAccessor syncBootStateAccessor)
|
||||
: base(publishedSnapshotAccessor, variationContextAccessor)
|
||||
{
|
||||
//if (Interlocked.Increment(ref _singletonCheck) > 1)
|
||||
@@ -99,6 +103,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
_globalSettings = globalSettings;
|
||||
_urlSegmentProviders = urlSegmentProviders;
|
||||
|
||||
_syncBootStateAccessor = syncBootStateAccessor;
|
||||
|
||||
// we need an Xml serializer here so that the member cache can support XPath,
|
||||
// for members this is done by navigating the serialized-to-xml member
|
||||
_entitySerializer = entitySerializer;
|
||||
@@ -217,7 +223,12 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
{
|
||||
var okContent = false;
|
||||
var okMedia = false;
|
||||
|
||||
if (_syncBootStateAccessor.GetSyncBootState() == SyncBootState.ColdBoot)
|
||||
{
|
||||
_logger.Info<PublishedSnapshotService>("Sync Service is in a Cold Boot state. Skip LoadCachesOnStartup as the Sync Service will trigger a full reload");
|
||||
_isReady = true;
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
if (_localContentDbExists)
|
||||
@@ -233,7 +244,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
if (!okMedia)
|
||||
_logger.Warn<PublishedSnapshotService>("Loading media from local db raised warnings, will reload from database.");
|
||||
}
|
||||
|
||||
|
||||
if (!okContent)
|
||||
LockAndLoadContent(scope => LoadContentFromDatabaseLocked(scope, true));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user