Files
Umbraco-CMS/src/Umbraco.PublishedCache.NuCache/PublishedSnapshotService.cs

1139 lines
51 KiB
C#
Raw Normal View History

using System;
2016-05-27 14:26:28 +02:00
using System.Collections.Generic;
using System.IO;
2016-05-27 14:26:28 +02:00
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
2016-05-27 14:26:28 +02:00
using CSharpTest.Net.Collections;
2020-09-15 12:40:35 +02:00
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.Logging;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.PublishedCache;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Runtime;
using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Services.Changes;
Examine 2.0 integration (#10241) * Init commit for examine 2.0 work, most old umb examine tests working, probably a lot that doesn't * Gets Umbraco Examine tests passing and makes some sense out of them, fixes some underlying issues. * Large refactor, remove TaskHelper, rename Notifications to be consistent, Gets all examine/lucene indexes building and startup ordered in the correct way, removes old files, creates new IUmbracoIndexingHandler for abstracting out all index operations for umbraco data, abstracts out IIndexRebuilder, Fixes Stack overflow with LiveModelsProvider and loading assemblies, ports some changes from v8 for startup handling with cold boots, refactors out LastSyncedFileManager * fix up issues with rebuilding and management dashboard. * removes old files, removes NetworkHelper, fixes LastSyncedFileManager implementation to ensure the machine name is used, fix up logging with cold boot state. * Makes MainDom safer to use and makes PublishedSnapshotService lazily register with MainDom * lazily acquire application id (fix unit tests) * Fixes resource casing and missing test file * Ensures caches when requiring internal services for PublishedSnapshotService, UseNuCache is a separate call, shouldn't be buried in AddWebComponents, was also causing issues in integration tests since nucache was being used for the Id2Key service. * For UmbracoTestServerTestBase enable nucache services * Fixing tests * Fix another test * Fixes tests, use TestHostingEnvironment, make Tests.Common use net5, remove old Lucene.Net.Contrib ref. * Fixes up some review notes * Fixes issue with doubly registering PublishedSnapshotService meanig there could be 2x instances of it * Checks for parseexception when executing the query * Use application root instead of duplicating functionality. * Added Examine project to netcore only solution file * Fixed casing issue with LazyLoad, that is not lowercase. * uses cancellationToken instead of bool flag, fixes always reading lastId from the LastSyncedFileManager, fixes RecurringHostedServiceBase so that there isn't an overlapping thread for the same task type * Fix tests * remove legacy test project from solution file * Fix test Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2021-05-18 18:31:38 +10:00
using Umbraco.Cms.Core.Sync;
using Umbraco.Cms.Infrastructure.PublishedCache.DataSource;
using Umbraco.Cms.Infrastructure.PublishedCache.Persistence;
using Umbraco.Extensions;
using Constants = Umbraco.Cms.Core.Constants;
2019-02-13 13:28:11 +01:00
using File = System.IO.File;
2016-05-27 14:26:28 +02:00
namespace Umbraco.Cms.Infrastructure.PublishedCache
2016-05-27 14:26:28 +02:00
{
internal class PublishedSnapshotService : IPublishedSnapshotService
2016-05-27 14:26:28 +02:00
{
Examine 2.0 integration (#10241) * Init commit for examine 2.0 work, most old umb examine tests working, probably a lot that doesn't * Gets Umbraco Examine tests passing and makes some sense out of them, fixes some underlying issues. * Large refactor, remove TaskHelper, rename Notifications to be consistent, Gets all examine/lucene indexes building and startup ordered in the correct way, removes old files, creates new IUmbracoIndexingHandler for abstracting out all index operations for umbraco data, abstracts out IIndexRebuilder, Fixes Stack overflow with LiveModelsProvider and loading assemblies, ports some changes from v8 for startup handling with cold boots, refactors out LastSyncedFileManager * fix up issues with rebuilding and management dashboard. * removes old files, removes NetworkHelper, fixes LastSyncedFileManager implementation to ensure the machine name is used, fix up logging with cold boot state. * Makes MainDom safer to use and makes PublishedSnapshotService lazily register with MainDom * lazily acquire application id (fix unit tests) * Fixes resource casing and missing test file * Ensures caches when requiring internal services for PublishedSnapshotService, UseNuCache is a separate call, shouldn't be buried in AddWebComponents, was also causing issues in integration tests since nucache was being used for the Id2Key service. * For UmbracoTestServerTestBase enable nucache services * Fixing tests * Fix another test * Fixes tests, use TestHostingEnvironment, make Tests.Common use net5, remove old Lucene.Net.Contrib ref. * Fixes up some review notes * Fixes issue with doubly registering PublishedSnapshotService meanig there could be 2x instances of it * Checks for parseexception when executing the query * Use application root instead of duplicating functionality. * Added Examine project to netcore only solution file * Fixed casing issue with LazyLoad, that is not lowercase. * uses cancellationToken instead of bool flag, fixes always reading lastId from the LastSyncedFileManager, fixes RecurringHostedServiceBase so that there isn't an overlapping thread for the same task type * Fix tests * remove legacy test project from solution file * Fix test Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2021-05-18 18:31:38 +10:00
private readonly PublishedSnapshotServiceOptions _options;
private readonly ISyncBootStateAccessor _syncBootStateAccessor;
private readonly IMainDom _mainDom;
2016-05-27 14:26:28 +02:00
private readonly ServiceContext _serviceContext;
2017-10-17 17:43:15 +02:00
private readonly IPublishedContentTypeFactory _publishedContentTypeFactory;
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
private readonly IVariationContextAccessor _variationContextAccessor;
2020-09-15 08:45:40 +02:00
private readonly IProfilingLogger _profilingLogger;
2017-05-12 14:49:44 +02:00
private readonly IScopeProvider _scopeProvider;
private readonly INuCacheContentService _publishedContentService;
2020-09-22 13:22:44 +02:00
private readonly ILogger<PublishedSnapshotService> _logger;
2020-09-15 12:40:35 +02:00
private readonly ILoggerFactory _loggerFactory;
private readonly GlobalSettings _globalSettings;
private readonly IPublishedModelFactory _publishedModelFactory;
2018-04-30 21:29:49 +02:00
private readonly IDefaultCultureAccessor _defaultCultureAccessor;
private readonly IHostingEnvironment _hostingEnvironment;
Merge commit '94d525d88f713b36419f28bfda4d82ee68637d83' into v9/dev # Conflicts: # build/NuSpecs/UmbracoCms.Web.nuspec # src/Umbraco.Core/Composing/Current.cs # src/Umbraco.Core/Persistence/NPocoDatabaseExtensions-Bulk.cs # src/Umbraco.Core/Runtime/CoreRuntime.cs # src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs # src/Umbraco.Infrastructure/Persistence/NPocoDatabaseExtensions.cs # src/Umbraco.Infrastructure/Persistence/UmbracoDatabase.cs # src/Umbraco.Persistence.SqlCe/SqlCeSyntaxProvider.cs # src/Umbraco.PublishedCache.NuCache/DataSource/BTree.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentCacheDataModel.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentCacheDataSerializationResult.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentCacheDataSerializerEntityType.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentData.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentNestedData.cs # src/Umbraco.PublishedCache.NuCache/DataSource/CultureVariation.cs # src/Umbraco.PublishedCache.NuCache/DataSource/IContentCacheDataSerializer.cs # src/Umbraco.PublishedCache.NuCache/DataSource/IContentCacheDataSerializerFactory.cs # src/Umbraco.PublishedCache.NuCache/DataSource/IDictionaryOfPropertyDataSerializer.cs # src/Umbraco.PublishedCache.NuCache/DataSource/JsonContentNestedDataSerializer.cs # src/Umbraco.PublishedCache.NuCache/DataSource/JsonContentNestedDataSerializerFactory.cs # src/Umbraco.PublishedCache.NuCache/DataSource/LazyCompressedString.cs # src/Umbraco.PublishedCache.NuCache/DataSource/MsgPackContentNestedDataSerializer.cs # src/Umbraco.PublishedCache.NuCache/DataSource/MsgPackContentNestedDataSerializerFactory.cs # src/Umbraco.PublishedCache.NuCache/DataSource/PropertyData.cs # src/Umbraco.PublishedCache.NuCache/NuCacheSerializerComponent.cs # src/Umbraco.PublishedCache.NuCache/NuCacheSerializerComposer.cs # src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentTypeServiceVariantsTests.cs # src/Umbraco.Tests/App.config # src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs # src/Umbraco.Tests/PublishedContent/NuCacheTests.cs # src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs # src/Umbraco.Web.UI.NetCore/umbraco/config/lang/da.xml # src/Umbraco.Web.UI/web.Template.Debug.config # src/Umbraco.Web.UI/web.Template.config # src/Umbraco.Web/Composing/ModuleInjector.cs # src/Umbraco.Web/Editors/NuCacheStatusController.cs # src/Umbraco.Web/PublishedCache/NuCache/DataSource/ContentNestedData.cs # src/Umbraco.Web/PublishedCache/NuCache/DataSource/DatabaseDataSource.cs # src/Umbraco.Web/PublishedCache/NuCache/NuCacheComposer.cs # src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs # src/Umbraco.Web/Runtime/WebRuntime.cs
2021-06-24 09:43:57 -06:00
private readonly ContentDataSerializer _contentDataSerializer;
private readonly NuCacheSettings _config;
2016-05-27 14:26:28 +02:00
private bool _isReady;
private bool _isReadSet;
private object? _isReadyLock;
2016-05-27 14:26:28 +02:00
private ContentStore _contentStore = null!;
private ContentStore _mediaStore = null!;
private SnapDictionary<int, Domain> _domainStore = null!;
2016-05-27 14:26:28 +02:00
private readonly object _storesLock = new object();
2020-01-06 21:14:46 +11:00
private readonly object _elementsLock = new object();
2016-05-27 14:26:28 +02:00
private BPlusTree<int, ContentNodeKit>? _localContentDb;
private BPlusTree<int, ContentNodeKit>? _localMediaDb;
private bool _localContentDbExists;
private bool _localMediaDbExists;
2016-05-27 14:26:28 +02:00
private long _contentGen;
private long _mediaGen;
private long _domainGen;
private IAppCache? _elementsCache;
2016-05-27 14:26:28 +02:00
// 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
// so making it configurable.
2016-05-27 14:26:28 +02:00
public static readonly bool FullCacheWhenPreviewing = true;
public PublishedSnapshotService(
PublishedSnapshotServiceOptions options,
Examine 2.0 integration (#10241) * Init commit for examine 2.0 work, most old umb examine tests working, probably a lot that doesn't * Gets Umbraco Examine tests passing and makes some sense out of them, fixes some underlying issues. * Large refactor, remove TaskHelper, rename Notifications to be consistent, Gets all examine/lucene indexes building and startup ordered in the correct way, removes old files, creates new IUmbracoIndexingHandler for abstracting out all index operations for umbraco data, abstracts out IIndexRebuilder, Fixes Stack overflow with LiveModelsProvider and loading assemblies, ports some changes from v8 for startup handling with cold boots, refactors out LastSyncedFileManager * fix up issues with rebuilding and management dashboard. * removes old files, removes NetworkHelper, fixes LastSyncedFileManager implementation to ensure the machine name is used, fix up logging with cold boot state. * Makes MainDom safer to use and makes PublishedSnapshotService lazily register with MainDom * lazily acquire application id (fix unit tests) * Fixes resource casing and missing test file * Ensures caches when requiring internal services for PublishedSnapshotService, UseNuCache is a separate call, shouldn't be buried in AddWebComponents, was also causing issues in integration tests since nucache was being used for the Id2Key service. * For UmbracoTestServerTestBase enable nucache services * Fixing tests * Fix another test * Fixes tests, use TestHostingEnvironment, make Tests.Common use net5, remove old Lucene.Net.Contrib ref. * Fixes up some review notes * Fixes issue with doubly registering PublishedSnapshotService meanig there could be 2x instances of it * Checks for parseexception when executing the query * Use application root instead of duplicating functionality. * Added Examine project to netcore only solution file * Fixed casing issue with LazyLoad, that is not lowercase. * uses cancellationToken instead of bool flag, fixes always reading lastId from the LastSyncedFileManager, fixes RecurringHostedServiceBase so that there isn't an overlapping thread for the same task type * Fix tests * remove legacy test project from solution file * Fix test Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2021-05-18 18:31:38 +10:00
ISyncBootStateAccessor syncBootStateAccessor,
IMainDom mainDom,
ServiceContext serviceContext,
IPublishedContentTypeFactory publishedContentTypeFactory,
IPublishedSnapshotAccessor publishedSnapshotAccessor,
IVariationContextAccessor variationContextAccessor,
IProfilingLogger profilingLogger,
2020-09-15 12:40:35 +02:00
ILoggerFactory loggerFactory,
2020-09-15 08:45:40 +02:00
IScopeProvider scopeProvider,
INuCacheContentService publishedContentService,
2018-04-30 21:29:49 +02:00
IDefaultCultureAccessor defaultCultureAccessor,
IOptions<GlobalSettings> globalSettings,
IPublishedModelFactory publishedModelFactory,
IHostingEnvironment hostingEnvironment,
Merge commit '94d525d88f713b36419f28bfda4d82ee68637d83' into v9/dev # Conflicts: # build/NuSpecs/UmbracoCms.Web.nuspec # src/Umbraco.Core/Composing/Current.cs # src/Umbraco.Core/Persistence/NPocoDatabaseExtensions-Bulk.cs # src/Umbraco.Core/Runtime/CoreRuntime.cs # src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs # src/Umbraco.Infrastructure/Persistence/NPocoDatabaseExtensions.cs # src/Umbraco.Infrastructure/Persistence/UmbracoDatabase.cs # src/Umbraco.Persistence.SqlCe/SqlCeSyntaxProvider.cs # src/Umbraco.PublishedCache.NuCache/DataSource/BTree.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentCacheDataModel.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentCacheDataSerializationResult.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentCacheDataSerializerEntityType.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentData.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentNestedData.cs # src/Umbraco.PublishedCache.NuCache/DataSource/CultureVariation.cs # src/Umbraco.PublishedCache.NuCache/DataSource/IContentCacheDataSerializer.cs # src/Umbraco.PublishedCache.NuCache/DataSource/IContentCacheDataSerializerFactory.cs # src/Umbraco.PublishedCache.NuCache/DataSource/IDictionaryOfPropertyDataSerializer.cs # src/Umbraco.PublishedCache.NuCache/DataSource/JsonContentNestedDataSerializer.cs # src/Umbraco.PublishedCache.NuCache/DataSource/JsonContentNestedDataSerializerFactory.cs # src/Umbraco.PublishedCache.NuCache/DataSource/LazyCompressedString.cs # src/Umbraco.PublishedCache.NuCache/DataSource/MsgPackContentNestedDataSerializer.cs # src/Umbraco.PublishedCache.NuCache/DataSource/MsgPackContentNestedDataSerializerFactory.cs # src/Umbraco.PublishedCache.NuCache/DataSource/PropertyData.cs # src/Umbraco.PublishedCache.NuCache/NuCacheSerializerComponent.cs # src/Umbraco.PublishedCache.NuCache/NuCacheSerializerComposer.cs # src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentTypeServiceVariantsTests.cs # src/Umbraco.Tests/App.config # src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs # src/Umbraco.Tests/PublishedContent/NuCacheTests.cs # src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs # src/Umbraco.Web.UI.NetCore/umbraco/config/lang/da.xml # src/Umbraco.Web.UI/web.Template.Debug.config # src/Umbraco.Web.UI/web.Template.config # src/Umbraco.Web/Composing/ModuleInjector.cs # src/Umbraco.Web/Editors/NuCacheStatusController.cs # src/Umbraco.Web/PublishedCache/NuCache/DataSource/ContentNestedData.cs # src/Umbraco.Web/PublishedCache/NuCache/DataSource/DatabaseDataSource.cs # src/Umbraco.Web/PublishedCache/NuCache/NuCacheComposer.cs # src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs # src/Umbraco.Web/Runtime/WebRuntime.cs
2021-06-24 09:43:57 -06:00
IOptions<NuCacheSettings> config,
ContentDataSerializer contentDataSerializer)
2016-05-27 14:26:28 +02:00
{
Examine 2.0 integration (#10241) * Init commit for examine 2.0 work, most old umb examine tests working, probably a lot that doesn't * Gets Umbraco Examine tests passing and makes some sense out of them, fixes some underlying issues. * Large refactor, remove TaskHelper, rename Notifications to be consistent, Gets all examine/lucene indexes building and startup ordered in the correct way, removes old files, creates new IUmbracoIndexingHandler for abstracting out all index operations for umbraco data, abstracts out IIndexRebuilder, Fixes Stack overflow with LiveModelsProvider and loading assemblies, ports some changes from v8 for startup handling with cold boots, refactors out LastSyncedFileManager * fix up issues with rebuilding and management dashboard. * removes old files, removes NetworkHelper, fixes LastSyncedFileManager implementation to ensure the machine name is used, fix up logging with cold boot state. * Makes MainDom safer to use and makes PublishedSnapshotService lazily register with MainDom * lazily acquire application id (fix unit tests) * Fixes resource casing and missing test file * Ensures caches when requiring internal services for PublishedSnapshotService, UseNuCache is a separate call, shouldn't be buried in AddWebComponents, was also causing issues in integration tests since nucache was being used for the Id2Key service. * For UmbracoTestServerTestBase enable nucache services * Fixing tests * Fix another test * Fixes tests, use TestHostingEnvironment, make Tests.Common use net5, remove old Lucene.Net.Contrib ref. * Fixes up some review notes * Fixes issue with doubly registering PublishedSnapshotService meanig there could be 2x instances of it * Checks for parseexception when executing the query * Use application root instead of duplicating functionality. * Added Examine project to netcore only solution file * Fixed casing issue with LazyLoad, that is not lowercase. * uses cancellationToken instead of bool flag, fixes always reading lastId from the LastSyncedFileManager, fixes RecurringHostedServiceBase so that there isn't an overlapping thread for the same task type * Fix tests * remove legacy test project from solution file * Fix test Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2021-05-18 18:31:38 +10:00
_options = options;
_syncBootStateAccessor = syncBootStateAccessor;
_mainDom = mainDom;
2016-05-27 14:26:28 +02:00
_serviceContext = serviceContext;
2017-10-17 17:43:15 +02:00
_publishedContentTypeFactory = publishedContentTypeFactory;
_publishedSnapshotAccessor = publishedSnapshotAccessor;
_variationContextAccessor = variationContextAccessor;
2020-09-15 08:45:40 +02:00
_profilingLogger = profilingLogger;
2020-09-15 12:40:35 +02:00
_loggerFactory = loggerFactory;
_logger = _loggerFactory.CreateLogger<PublishedSnapshotService>();
2017-05-12 14:49:44 +02:00
_scopeProvider = scopeProvider;
_publishedContentService = publishedContentService;
2018-04-30 21:29:49 +02:00
_defaultCultureAccessor = defaultCultureAccessor;
_globalSettings = globalSettings.Value;
_hostingEnvironment = hostingEnvironment;
Merge commit '94d525d88f713b36419f28bfda4d82ee68637d83' into v9/dev # Conflicts: # build/NuSpecs/UmbracoCms.Web.nuspec # src/Umbraco.Core/Composing/Current.cs # src/Umbraco.Core/Persistence/NPocoDatabaseExtensions-Bulk.cs # src/Umbraco.Core/Runtime/CoreRuntime.cs # src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs # src/Umbraco.Infrastructure/Persistence/NPocoDatabaseExtensions.cs # src/Umbraco.Infrastructure/Persistence/UmbracoDatabase.cs # src/Umbraco.Persistence.SqlCe/SqlCeSyntaxProvider.cs # src/Umbraco.PublishedCache.NuCache/DataSource/BTree.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentCacheDataModel.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentCacheDataSerializationResult.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentCacheDataSerializerEntityType.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentData.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentNestedData.cs # src/Umbraco.PublishedCache.NuCache/DataSource/CultureVariation.cs # src/Umbraco.PublishedCache.NuCache/DataSource/IContentCacheDataSerializer.cs # src/Umbraco.PublishedCache.NuCache/DataSource/IContentCacheDataSerializerFactory.cs # src/Umbraco.PublishedCache.NuCache/DataSource/IDictionaryOfPropertyDataSerializer.cs # src/Umbraco.PublishedCache.NuCache/DataSource/JsonContentNestedDataSerializer.cs # src/Umbraco.PublishedCache.NuCache/DataSource/JsonContentNestedDataSerializerFactory.cs # src/Umbraco.PublishedCache.NuCache/DataSource/LazyCompressedString.cs # src/Umbraco.PublishedCache.NuCache/DataSource/MsgPackContentNestedDataSerializer.cs # src/Umbraco.PublishedCache.NuCache/DataSource/MsgPackContentNestedDataSerializerFactory.cs # src/Umbraco.PublishedCache.NuCache/DataSource/PropertyData.cs # src/Umbraco.PublishedCache.NuCache/NuCacheSerializerComponent.cs # src/Umbraco.PublishedCache.NuCache/NuCacheSerializerComposer.cs # src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentTypeServiceVariantsTests.cs # src/Umbraco.Tests/App.config # src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs # src/Umbraco.Tests/PublishedContent/NuCacheTests.cs # src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs # src/Umbraco.Web.UI.NetCore/umbraco/config/lang/da.xml # src/Umbraco.Web.UI/web.Template.Debug.config # src/Umbraco.Web.UI/web.Template.config # src/Umbraco.Web/Composing/ModuleInjector.cs # src/Umbraco.Web/Editors/NuCacheStatusController.cs # src/Umbraco.Web/PublishedCache/NuCache/DataSource/ContentNestedData.cs # src/Umbraco.Web/PublishedCache/NuCache/DataSource/DatabaseDataSource.cs # src/Umbraco.Web/PublishedCache/NuCache/NuCacheComposer.cs # src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs # src/Umbraco.Web/Runtime/WebRuntime.cs
2021-06-24 09:43:57 -06:00
_contentDataSerializer = contentDataSerializer;
_config = config.Value;
_publishedModelFactory = publishedModelFactory;
}
2018-03-30 14:00:44 +02:00
protected PublishedSnapshot? CurrentPublishedSnapshot
2021-08-17 13:10:13 +02:00
{
get
{
_publishedSnapshotAccessor.TryGetPublishedSnapshot(out var publishedSnapshot);
return (PublishedSnapshot?)publishedSnapshot;
2021-08-17 13:10:13 +02:00
}
}
// NOTE: These aren't used within this object but are made available internally to improve the IdKey lookup performance
// when nucache is enabled.
// TODO: Does this need to be here?
Examine 2.0 integration (#10241) * Init commit for examine 2.0 work, most old umb examine tests working, probably a lot that doesn't * Gets Umbraco Examine tests passing and makes some sense out of them, fixes some underlying issues. * Large refactor, remove TaskHelper, rename Notifications to be consistent, Gets all examine/lucene indexes building and startup ordered in the correct way, removes old files, creates new IUmbracoIndexingHandler for abstracting out all index operations for umbraco data, abstracts out IIndexRebuilder, Fixes Stack overflow with LiveModelsProvider and loading assemblies, ports some changes from v8 for startup handling with cold boots, refactors out LastSyncedFileManager * fix up issues with rebuilding and management dashboard. * removes old files, removes NetworkHelper, fixes LastSyncedFileManager implementation to ensure the machine name is used, fix up logging with cold boot state. * Makes MainDom safer to use and makes PublishedSnapshotService lazily register with MainDom * lazily acquire application id (fix unit tests) * Fixes resource casing and missing test file * Ensures caches when requiring internal services for PublishedSnapshotService, UseNuCache is a separate call, shouldn't be buried in AddWebComponents, was also causing issues in integration tests since nucache was being used for the Id2Key service. * For UmbracoTestServerTestBase enable nucache services * Fixing tests * Fix another test * Fixes tests, use TestHostingEnvironment, make Tests.Common use net5, remove old Lucene.Net.Contrib ref. * Fixes up some review notes * Fixes issue with doubly registering PublishedSnapshotService meanig there could be 2x instances of it * Checks for parseexception when executing the query * Use application root instead of duplicating functionality. * Added Examine project to netcore only solution file * Fixed casing issue with LazyLoad, that is not lowercase. * uses cancellationToken instead of bool flag, fixes always reading lastId from the LastSyncedFileManager, fixes RecurringHostedServiceBase so that there isn't an overlapping thread for the same task type * Fix tests * remove legacy test project from solution file * Fix test Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2021-05-18 18:31:38 +10:00
internal int GetDocumentId(Guid udi)
{
EnsureCaches();
return GetId(_contentStore, udi);
}
Examine 2.0 integration (#10241) * Init commit for examine 2.0 work, most old umb examine tests working, probably a lot that doesn't * Gets Umbraco Examine tests passing and makes some sense out of them, fixes some underlying issues. * Large refactor, remove TaskHelper, rename Notifications to be consistent, Gets all examine/lucene indexes building and startup ordered in the correct way, removes old files, creates new IUmbracoIndexingHandler for abstracting out all index operations for umbraco data, abstracts out IIndexRebuilder, Fixes Stack overflow with LiveModelsProvider and loading assemblies, ports some changes from v8 for startup handling with cold boots, refactors out LastSyncedFileManager * fix up issues with rebuilding and management dashboard. * removes old files, removes NetworkHelper, fixes LastSyncedFileManager implementation to ensure the machine name is used, fix up logging with cold boot state. * Makes MainDom safer to use and makes PublishedSnapshotService lazily register with MainDom * lazily acquire application id (fix unit tests) * Fixes resource casing and missing test file * Ensures caches when requiring internal services for PublishedSnapshotService, UseNuCache is a separate call, shouldn't be buried in AddWebComponents, was also causing issues in integration tests since nucache was being used for the Id2Key service. * For UmbracoTestServerTestBase enable nucache services * Fixing tests * Fix another test * Fixes tests, use TestHostingEnvironment, make Tests.Common use net5, remove old Lucene.Net.Contrib ref. * Fixes up some review notes * Fixes issue with doubly registering PublishedSnapshotService meanig there could be 2x instances of it * Checks for parseexception when executing the query * Use application root instead of duplicating functionality. * Added Examine project to netcore only solution file * Fixed casing issue with LazyLoad, that is not lowercase. * uses cancellationToken instead of bool flag, fixes always reading lastId from the LastSyncedFileManager, fixes RecurringHostedServiceBase so that there isn't an overlapping thread for the same task type * Fix tests * remove legacy test project from solution file * Fix test Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2021-05-18 18:31:38 +10:00
internal int GetMediaId(Guid udi)
{
EnsureCaches();
return GetId(_mediaStore, udi);
}
Examine 2.0 integration (#10241) * Init commit for examine 2.0 work, most old umb examine tests working, probably a lot that doesn't * Gets Umbraco Examine tests passing and makes some sense out of them, fixes some underlying issues. * Large refactor, remove TaskHelper, rename Notifications to be consistent, Gets all examine/lucene indexes building and startup ordered in the correct way, removes old files, creates new IUmbracoIndexingHandler for abstracting out all index operations for umbraco data, abstracts out IIndexRebuilder, Fixes Stack overflow with LiveModelsProvider and loading assemblies, ports some changes from v8 for startup handling with cold boots, refactors out LastSyncedFileManager * fix up issues with rebuilding and management dashboard. * removes old files, removes NetworkHelper, fixes LastSyncedFileManager implementation to ensure the machine name is used, fix up logging with cold boot state. * Makes MainDom safer to use and makes PublishedSnapshotService lazily register with MainDom * lazily acquire application id (fix unit tests) * Fixes resource casing and missing test file * Ensures caches when requiring internal services for PublishedSnapshotService, UseNuCache is a separate call, shouldn't be buried in AddWebComponents, was also causing issues in integration tests since nucache was being used for the Id2Key service. * For UmbracoTestServerTestBase enable nucache services * Fixing tests * Fix another test * Fixes tests, use TestHostingEnvironment, make Tests.Common use net5, remove old Lucene.Net.Contrib ref. * Fixes up some review notes * Fixes issue with doubly registering PublishedSnapshotService meanig there could be 2x instances of it * Checks for parseexception when executing the query * Use application root instead of duplicating functionality. * Added Examine project to netcore only solution file * Fixed casing issue with LazyLoad, that is not lowercase. * uses cancellationToken instead of bool flag, fixes always reading lastId from the LastSyncedFileManager, fixes RecurringHostedServiceBase so that there isn't an overlapping thread for the same task type * Fix tests * remove legacy test project from solution file * Fix test Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2021-05-18 18:31:38 +10:00
internal Guid GetDocumentUid(int id)
{
EnsureCaches();
return GetUid(_contentStore, id);
}
Examine 2.0 integration (#10241) * Init commit for examine 2.0 work, most old umb examine tests working, probably a lot that doesn't * Gets Umbraco Examine tests passing and makes some sense out of them, fixes some underlying issues. * Large refactor, remove TaskHelper, rename Notifications to be consistent, Gets all examine/lucene indexes building and startup ordered in the correct way, removes old files, creates new IUmbracoIndexingHandler for abstracting out all index operations for umbraco data, abstracts out IIndexRebuilder, Fixes Stack overflow with LiveModelsProvider and loading assemblies, ports some changes from v8 for startup handling with cold boots, refactors out LastSyncedFileManager * fix up issues with rebuilding and management dashboard. * removes old files, removes NetworkHelper, fixes LastSyncedFileManager implementation to ensure the machine name is used, fix up logging with cold boot state. * Makes MainDom safer to use and makes PublishedSnapshotService lazily register with MainDom * lazily acquire application id (fix unit tests) * Fixes resource casing and missing test file * Ensures caches when requiring internal services for PublishedSnapshotService, UseNuCache is a separate call, shouldn't be buried in AddWebComponents, was also causing issues in integration tests since nucache was being used for the Id2Key service. * For UmbracoTestServerTestBase enable nucache services * Fixing tests * Fix another test * Fixes tests, use TestHostingEnvironment, make Tests.Common use net5, remove old Lucene.Net.Contrib ref. * Fixes up some review notes * Fixes issue with doubly registering PublishedSnapshotService meanig there could be 2x instances of it * Checks for parseexception when executing the query * Use application root instead of duplicating functionality. * Added Examine project to netcore only solution file * Fixed casing issue with LazyLoad, that is not lowercase. * uses cancellationToken instead of bool flag, fixes always reading lastId from the LastSyncedFileManager, fixes RecurringHostedServiceBase so that there isn't an overlapping thread for the same task type * Fix tests * remove legacy test project from solution file * Fix test Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2021-05-18 18:31:38 +10:00
internal Guid GetMediaUid(int id)
{
EnsureCaches();
return GetUid(_mediaStore, id);
}
private int GetId(ContentStore? store, Guid uid) => store?.LiveSnapshot.Get(uid)?.Id ?? 0;
private Guid GetUid(ContentStore? store, int id) => store?.LiveSnapshot.Get(id)?.Uid ?? Guid.Empty;
2016-05-27 14:26:28 +02:00
/// <summary>
/// Install phase of <see cref="IMainDom"/>
/// </summary>
/// <remarks>
/// This is inside of a lock in MainDom so this is guaranteed to run if MainDom was acquired and guaranteed
/// to not run if MainDom wasn't acquired.
/// If MainDom was not acquired, then _localContentDb and _localMediaDb will remain null which means this appdomain
/// will load in published content via the DB and in that case this appdomain will probably not exist long enough to
2019-11-05 12:54:22 +01:00
/// serve more than a page of content.
/// </remarks>
private void MainDomRegister()
{
var path = GetLocalFilesPath();
var localContentDbPath = Path.Combine(path, "NuCache.Content.db");
var localMediaDbPath = Path.Combine(path, "NuCache.Media.db");
2019-12-04 16:09:39 +11:00
_localContentDbExists = File.Exists(localContentDbPath);
_localMediaDbExists = File.Exists(localMediaDbPath);
// if both local databases exist then GetTree will open them, else new databases will be created
Merge commit '94d525d88f713b36419f28bfda4d82ee68637d83' into v9/dev # Conflicts: # build/NuSpecs/UmbracoCms.Web.nuspec # src/Umbraco.Core/Composing/Current.cs # src/Umbraco.Core/Persistence/NPocoDatabaseExtensions-Bulk.cs # src/Umbraco.Core/Runtime/CoreRuntime.cs # src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs # src/Umbraco.Infrastructure/Persistence/NPocoDatabaseExtensions.cs # src/Umbraco.Infrastructure/Persistence/UmbracoDatabase.cs # src/Umbraco.Persistence.SqlCe/SqlCeSyntaxProvider.cs # src/Umbraco.PublishedCache.NuCache/DataSource/BTree.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentCacheDataModel.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentCacheDataSerializationResult.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentCacheDataSerializerEntityType.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentData.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentNestedData.cs # src/Umbraco.PublishedCache.NuCache/DataSource/CultureVariation.cs # src/Umbraco.PublishedCache.NuCache/DataSource/IContentCacheDataSerializer.cs # src/Umbraco.PublishedCache.NuCache/DataSource/IContentCacheDataSerializerFactory.cs # src/Umbraco.PublishedCache.NuCache/DataSource/IDictionaryOfPropertyDataSerializer.cs # src/Umbraco.PublishedCache.NuCache/DataSource/JsonContentNestedDataSerializer.cs # src/Umbraco.PublishedCache.NuCache/DataSource/JsonContentNestedDataSerializerFactory.cs # src/Umbraco.PublishedCache.NuCache/DataSource/LazyCompressedString.cs # src/Umbraco.PublishedCache.NuCache/DataSource/MsgPackContentNestedDataSerializer.cs # src/Umbraco.PublishedCache.NuCache/DataSource/MsgPackContentNestedDataSerializerFactory.cs # src/Umbraco.PublishedCache.NuCache/DataSource/PropertyData.cs # src/Umbraco.PublishedCache.NuCache/NuCacheSerializerComponent.cs # src/Umbraco.PublishedCache.NuCache/NuCacheSerializerComposer.cs # src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentTypeServiceVariantsTests.cs # src/Umbraco.Tests/App.config # src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs # src/Umbraco.Tests/PublishedContent/NuCacheTests.cs # src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs # src/Umbraco.Web.UI.NetCore/umbraco/config/lang/da.xml # src/Umbraco.Web.UI/web.Template.Debug.config # src/Umbraco.Web.UI/web.Template.config # src/Umbraco.Web/Composing/ModuleInjector.cs # src/Umbraco.Web/Editors/NuCacheStatusController.cs # src/Umbraco.Web/PublishedCache/NuCache/DataSource/ContentNestedData.cs # src/Umbraco.Web/PublishedCache/NuCache/DataSource/DatabaseDataSource.cs # src/Umbraco.Web/PublishedCache/NuCache/NuCacheComposer.cs # src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs # src/Umbraco.Web/Runtime/WebRuntime.cs
2021-06-24 09:43:57 -06:00
_localContentDb = BTree.GetTree(localContentDbPath, _localContentDbExists, _config, _contentDataSerializer);
_localMediaDb = BTree.GetTree(localMediaDbPath, _localMediaDbExists, _config, _contentDataSerializer);
2020-09-15 08:45:40 +02:00
_logger.LogInformation("Registered with MainDom, localContentDbExists? {LocalContentDbExists}, localMediaDbExists? {LocalMediaDbExists}", _localContentDbExists, _localMediaDbExists);
}
/// <summary>
/// Release phase of MainDom
/// </summary>
/// <remarks>
/// This will execute on a threadpool thread
/// </remarks>
private void MainDomRelease()
2016-05-27 14:26:28 +02:00
{
2020-09-15 08:45:40 +02:00
_logger.LogDebug("Releasing from MainDom...");
2016-05-27 14:26:28 +02:00
lock (_storesLock)
{
2020-09-15 08:45:40 +02:00
_logger.LogDebug("Releasing content store...");
_contentStore?.ReleaseLocalDb(); // null check because we could shut down before being assigned
_localContentDb = null;
2020-09-15 08:45:40 +02:00
_logger.LogDebug("Releasing media store...");
_mediaStore?.ReleaseLocalDb(); // null check because we could shut down before being assigned
_localMediaDb = null;
2016-05-27 14:26:28 +02:00
2020-09-15 08:45:40 +02:00
_logger.LogInformation("Released from MainDom");
}
}
2019-02-13 13:28:11 +01:00
private string GetLocalFilesPath()
{
var path = Path.Combine(_hostingEnvironment.LocalTempPath, "NuCache");
2019-02-13 13:28:11 +01:00
if (!Directory.Exists(path))
{
2019-02-13 13:28:11 +01:00
Directory.CreateDirectory(path);
}
2019-02-13 13:28:11 +01:00
return path;
}
/// <summary>
Examine 2.0 integration (#10241) * Init commit for examine 2.0 work, most old umb examine tests working, probably a lot that doesn't * Gets Umbraco Examine tests passing and makes some sense out of them, fixes some underlying issues. * Large refactor, remove TaskHelper, rename Notifications to be consistent, Gets all examine/lucene indexes building and startup ordered in the correct way, removes old files, creates new IUmbracoIndexingHandler for abstracting out all index operations for umbraco data, abstracts out IIndexRebuilder, Fixes Stack overflow with LiveModelsProvider and loading assemblies, ports some changes from v8 for startup handling with cold boots, refactors out LastSyncedFileManager * fix up issues with rebuilding and management dashboard. * removes old files, removes NetworkHelper, fixes LastSyncedFileManager implementation to ensure the machine name is used, fix up logging with cold boot state. * Makes MainDom safer to use and makes PublishedSnapshotService lazily register with MainDom * lazily acquire application id (fix unit tests) * Fixes resource casing and missing test file * Ensures caches when requiring internal services for PublishedSnapshotService, UseNuCache is a separate call, shouldn't be buried in AddWebComponents, was also causing issues in integration tests since nucache was being used for the Id2Key service. * For UmbracoTestServerTestBase enable nucache services * Fixing tests * Fix another test * Fixes tests, use TestHostingEnvironment, make Tests.Common use net5, remove old Lucene.Net.Contrib ref. * Fixes up some review notes * Fixes issue with doubly registering PublishedSnapshotService meanig there could be 2x instances of it * Checks for parseexception when executing the query * Use application root instead of duplicating functionality. * Added Examine project to netcore only solution file * Fixed casing issue with LazyLoad, that is not lowercase. * uses cancellationToken instead of bool flag, fixes always reading lastId from the LastSyncedFileManager, fixes RecurringHostedServiceBase so that there isn't an overlapping thread for the same task type * Fix tests * remove legacy test project from solution file * Fix test Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2021-05-18 18:31:38 +10:00
/// Lazily populates the stores only when they are first requested
/// </summary>
internal void EnsureCaches() => LazyInitializer.EnsureInitialized(
ref _isReady,
ref _isReadSet,
ref _isReadyLock,
() =>
{
Examine 2.0 integration (#10241) * Init commit for examine 2.0 work, most old umb examine tests working, probably a lot that doesn't * Gets Umbraco Examine tests passing and makes some sense out of them, fixes some underlying issues. * Large refactor, remove TaskHelper, rename Notifications to be consistent, Gets all examine/lucene indexes building and startup ordered in the correct way, removes old files, creates new IUmbracoIndexingHandler for abstracting out all index operations for umbraco data, abstracts out IIndexRebuilder, Fixes Stack overflow with LiveModelsProvider and loading assemblies, ports some changes from v8 for startup handling with cold boots, refactors out LastSyncedFileManager * fix up issues with rebuilding and management dashboard. * removes old files, removes NetworkHelper, fixes LastSyncedFileManager implementation to ensure the machine name is used, fix up logging with cold boot state. * Makes MainDom safer to use and makes PublishedSnapshotService lazily register with MainDom * lazily acquire application id (fix unit tests) * Fixes resource casing and missing test file * Ensures caches when requiring internal services for PublishedSnapshotService, UseNuCache is a separate call, shouldn't be buried in AddWebComponents, was also causing issues in integration tests since nucache was being used for the Id2Key service. * For UmbracoTestServerTestBase enable nucache services * Fixing tests * Fix another test * Fixes tests, use TestHostingEnvironment, make Tests.Common use net5, remove old Lucene.Net.Contrib ref. * Fixes up some review notes * Fixes issue with doubly registering PublishedSnapshotService meanig there could be 2x instances of it * Checks for parseexception when executing the query * Use application root instead of duplicating functionality. * Added Examine project to netcore only solution file * Fixed casing issue with LazyLoad, that is not lowercase. * uses cancellationToken instead of bool flag, fixes always reading lastId from the LastSyncedFileManager, fixes RecurringHostedServiceBase so that there isn't an overlapping thread for the same task type * Fix tests * remove legacy test project from solution file * Fix test Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2021-05-18 18:31:38 +10:00
// lock this entire call, we only want a single thread to be accessing the stores at once and within
// the call below to mainDom.Register, a callback may occur on a threadpool thread to MainDomRelease
// at the same time as we are trying to write to the stores. MainDomRelease also locks on _storesLock so
// it will not be able to close the stores until we are done populating (if the store is empty)
lock (_storesLock)
{
Examine 2.0 integration (#10241) * Init commit for examine 2.0 work, most old umb examine tests working, probably a lot that doesn't * Gets Umbraco Examine tests passing and makes some sense out of them, fixes some underlying issues. * Large refactor, remove TaskHelper, rename Notifications to be consistent, Gets all examine/lucene indexes building and startup ordered in the correct way, removes old files, creates new IUmbracoIndexingHandler for abstracting out all index operations for umbraco data, abstracts out IIndexRebuilder, Fixes Stack overflow with LiveModelsProvider and loading assemblies, ports some changes from v8 for startup handling with cold boots, refactors out LastSyncedFileManager * fix up issues with rebuilding and management dashboard. * removes old files, removes NetworkHelper, fixes LastSyncedFileManager implementation to ensure the machine name is used, fix up logging with cold boot state. * Makes MainDom safer to use and makes PublishedSnapshotService lazily register with MainDom * lazily acquire application id (fix unit tests) * Fixes resource casing and missing test file * Ensures caches when requiring internal services for PublishedSnapshotService, UseNuCache is a separate call, shouldn't be buried in AddWebComponents, was also causing issues in integration tests since nucache was being used for the Id2Key service. * For UmbracoTestServerTestBase enable nucache services * Fixing tests * Fix another test * Fixes tests, use TestHostingEnvironment, make Tests.Common use net5, remove old Lucene.Net.Contrib ref. * Fixes up some review notes * Fixes issue with doubly registering PublishedSnapshotService meanig there could be 2x instances of it * Checks for parseexception when executing the query * Use application root instead of duplicating functionality. * Added Examine project to netcore only solution file * Fixed casing issue with LazyLoad, that is not lowercase. * uses cancellationToken instead of bool flag, fixes always reading lastId from the LastSyncedFileManager, fixes RecurringHostedServiceBase so that there isn't an overlapping thread for the same task type * Fix tests * remove legacy test project from solution file * Fix test Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2021-05-18 18:31:38 +10:00
if (!_options.IgnoreLocalDb)
{
_mainDom.Register(MainDomRegister, MainDomRelease);
// stores are created with a db so they can write to it, but they do not read from it,
// stores need to be populated, happens in OnResolutionFrozen which uses _localDbExists to
// figure out whether it can read the databases or it should populate them from sql
_logger.LogInformation("Creating the content store, localContentDbExists? {LocalContentDbExists}", _localContentDbExists);
_contentStore = new ContentStore(_publishedSnapshotAccessor, _variationContextAccessor, _loggerFactory.CreateLogger("ContentStore"), _loggerFactory, _publishedModelFactory, _localContentDb);
_logger.LogInformation("Creating the media store, localMediaDbExists? {LocalMediaDbExists}", _localMediaDbExists);
_mediaStore = new ContentStore(_publishedSnapshotAccessor, _variationContextAccessor, _loggerFactory.CreateLogger("ContentStore"), _loggerFactory, _publishedModelFactory, _localMediaDb);
}
else
{
_logger.LogInformation("Creating the content store (local db ignored)");
_contentStore = new ContentStore(_publishedSnapshotAccessor, _variationContextAccessor, _loggerFactory.CreateLogger("ContentStore"), _loggerFactory, _publishedModelFactory);
_logger.LogInformation("Creating the media store (local db ignored)");
_mediaStore = new ContentStore(_publishedSnapshotAccessor, _variationContextAccessor, _loggerFactory.CreateLogger("ContentStore"), _loggerFactory, _publishedModelFactory);
}
_domainStore = new SnapDictionary<int, Domain>();
var okContent = false;
var okMedia = false;
Examine 2.0 integration (#10241) * Init commit for examine 2.0 work, most old umb examine tests working, probably a lot that doesn't * Gets Umbraco Examine tests passing and makes some sense out of them, fixes some underlying issues. * Large refactor, remove TaskHelper, rename Notifications to be consistent, Gets all examine/lucene indexes building and startup ordered in the correct way, removes old files, creates new IUmbracoIndexingHandler for abstracting out all index operations for umbraco data, abstracts out IIndexRebuilder, Fixes Stack overflow with LiveModelsProvider and loading assemblies, ports some changes from v8 for startup handling with cold boots, refactors out LastSyncedFileManager * fix up issues with rebuilding and management dashboard. * removes old files, removes NetworkHelper, fixes LastSyncedFileManager implementation to ensure the machine name is used, fix up logging with cold boot state. * Makes MainDom safer to use and makes PublishedSnapshotService lazily register with MainDom * lazily acquire application id (fix unit tests) * Fixes resource casing and missing test file * Ensures caches when requiring internal services for PublishedSnapshotService, UseNuCache is a separate call, shouldn't be buried in AddWebComponents, was also causing issues in integration tests since nucache was being used for the Id2Key service. * For UmbracoTestServerTestBase enable nucache services * Fixing tests * Fix another test * Fixes tests, use TestHostingEnvironment, make Tests.Common use net5, remove old Lucene.Net.Contrib ref. * Fixes up some review notes * Fixes issue with doubly registering PublishedSnapshotService meanig there could be 2x instances of it * Checks for parseexception when executing the query * Use application root instead of duplicating functionality. * Added Examine project to netcore only solution file * Fixed casing issue with LazyLoad, that is not lowercase. * uses cancellationToken instead of bool flag, fixes always reading lastId from the LastSyncedFileManager, fixes RecurringHostedServiceBase so that there isn't an overlapping thread for the same task type * Fix tests * remove legacy test project from solution file * Fix test Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2021-05-18 18:31:38 +10:00
SyncBootState bootState = _syncBootStateAccessor.GetSyncBootState();
try
{
Examine 2.0 integration (#10241) * Init commit for examine 2.0 work, most old umb examine tests working, probably a lot that doesn't * Gets Umbraco Examine tests passing and makes some sense out of them, fixes some underlying issues. * Large refactor, remove TaskHelper, rename Notifications to be consistent, Gets all examine/lucene indexes building and startup ordered in the correct way, removes old files, creates new IUmbracoIndexingHandler for abstracting out all index operations for umbraco data, abstracts out IIndexRebuilder, Fixes Stack overflow with LiveModelsProvider and loading assemblies, ports some changes from v8 for startup handling with cold boots, refactors out LastSyncedFileManager * fix up issues with rebuilding and management dashboard. * removes old files, removes NetworkHelper, fixes LastSyncedFileManager implementation to ensure the machine name is used, fix up logging with cold boot state. * Makes MainDom safer to use and makes PublishedSnapshotService lazily register with MainDom * lazily acquire application id (fix unit tests) * Fixes resource casing and missing test file * Ensures caches when requiring internal services for PublishedSnapshotService, UseNuCache is a separate call, shouldn't be buried in AddWebComponents, was also causing issues in integration tests since nucache was being used for the Id2Key service. * For UmbracoTestServerTestBase enable nucache services * Fixing tests * Fix another test * Fixes tests, use TestHostingEnvironment, make Tests.Common use net5, remove old Lucene.Net.Contrib ref. * Fixes up some review notes * Fixes issue with doubly registering PublishedSnapshotService meanig there could be 2x instances of it * Checks for parseexception when executing the query * Use application root instead of duplicating functionality. * Added Examine project to netcore only solution file * Fixed casing issue with LazyLoad, that is not lowercase. * uses cancellationToken instead of bool flag, fixes always reading lastId from the LastSyncedFileManager, fixes RecurringHostedServiceBase so that there isn't an overlapping thread for the same task type * Fix tests * remove legacy test project from solution file * Fix test Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2021-05-18 18:31:38 +10:00
if (bootState != SyncBootState.ColdBoot && _localContentDbExists)
{
okContent = LockAndLoadContent(() => LoadContentFromLocalDbLocked(true));
if (!okContent)
{
_logger.LogWarning("Loading content from local db raised warnings, will reload from database.");
}
}
2016-06-30 10:30:43 +02:00
Examine 2.0 integration (#10241) * Init commit for examine 2.0 work, most old umb examine tests working, probably a lot that doesn't * Gets Umbraco Examine tests passing and makes some sense out of them, fixes some underlying issues. * Large refactor, remove TaskHelper, rename Notifications to be consistent, Gets all examine/lucene indexes building and startup ordered in the correct way, removes old files, creates new IUmbracoIndexingHandler for abstracting out all index operations for umbraco data, abstracts out IIndexRebuilder, Fixes Stack overflow with LiveModelsProvider and loading assemblies, ports some changes from v8 for startup handling with cold boots, refactors out LastSyncedFileManager * fix up issues with rebuilding and management dashboard. * removes old files, removes NetworkHelper, fixes LastSyncedFileManager implementation to ensure the machine name is used, fix up logging with cold boot state. * Makes MainDom safer to use and makes PublishedSnapshotService lazily register with MainDom * lazily acquire application id (fix unit tests) * Fixes resource casing and missing test file * Ensures caches when requiring internal services for PublishedSnapshotService, UseNuCache is a separate call, shouldn't be buried in AddWebComponents, was also causing issues in integration tests since nucache was being used for the Id2Key service. * For UmbracoTestServerTestBase enable nucache services * Fixing tests * Fix another test * Fixes tests, use TestHostingEnvironment, make Tests.Common use net5, remove old Lucene.Net.Contrib ref. * Fixes up some review notes * Fixes issue with doubly registering PublishedSnapshotService meanig there could be 2x instances of it * Checks for parseexception when executing the query * Use application root instead of duplicating functionality. * Added Examine project to netcore only solution file * Fixed casing issue with LazyLoad, that is not lowercase. * uses cancellationToken instead of bool flag, fixes always reading lastId from the LastSyncedFileManager, fixes RecurringHostedServiceBase so that there isn't an overlapping thread for the same task type * Fix tests * remove legacy test project from solution file * Fix test Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2021-05-18 18:31:38 +10:00
if (bootState != SyncBootState.ColdBoot && _localMediaDbExists)
{
okMedia = LockAndLoadMedia(() => LoadMediaFromLocalDbLocked(true));
if (!okMedia)
{
_logger.LogWarning("Loading media from local db raised warnings, will reload from database.");
}
}
if (!okContent)
{
LockAndLoadContent(() => LoadContentFromDatabaseLocked(true));
}
if (!okMedia)
{
LockAndLoadMedia(() => LoadMediaFromDatabaseLocked(true));
}
LockAndLoadDomains();
}
catch (Exception ex)
{
_logger.LogCritical(ex, "Panic, exception while loading cache data.");
throw;
}
return true;
}
});
2016-05-27 14:26:28 +02:00
// sudden panic... but in RepeatableRead can a content that I haven't already read, be removed
// before I read it? NO! because the WHOLE content tree is read-locked using WithReadLocked.
// don't panic.
private bool LockAndLoadContent(Func<bool> action)
{
// first get a writer, then a scope
// if there already is a scope, the writer will attach to it
// otherwise, it will only exist here - cheap
using (_contentStore?.GetScopedWriteLock(_scopeProvider))
using (var scope = _scopeProvider.CreateScope())
{
scope.ReadLock(Constants.Locks.ContentTree);
var ok = action();
scope.Complete();
return ok;
}
}
private bool LoadContentFromDatabaseLocked(bool onStartup)
2016-05-27 14:26:28 +02:00
{
// locks:
// contentStore is wlocked (1 thread)
// content (and types) are read-locked
var contentTypes = _serviceContext.ContentTypeService?.GetAll().ToList();
_contentStore.SetAllContentTypesLocked(contentTypes?.Select(x => _publishedContentTypeFactory.CreateContentType(x)));
2020-09-15 08:45:40 +02:00
using (_profilingLogger.TraceDuration<PublishedSnapshotService>("Loading content from database"))
{
// beware! at that point the cache is inconsistent,
// assuming we are going to SetAll content items!
2016-05-27 14:26:28 +02:00
_localContentDb?.Clear();
2016-05-27 14:26:28 +02:00
2019-08-19 17:18:45 +10:00
// IMPORTANT GetAllContentSources sorts kits by level + parentId + sortOrder
try
{
var kits = _publishedContentService.GetAllContentSources();
return onStartup ? _contentStore.SetAllFastSortedLocked(kits, _config.KitBatchSize, true) : _contentStore.SetAllLocked(kits, _config.KitBatchSize, true);
}
catch (ThreadAbortException tae)
{
// Caught a ThreadAbortException, most likely from a database timeout.
// If we don't catch it here, the whole local cache can remain locked causing widespread panic (see above comment).
_logger.LogWarning(tae, tae.Message);
}
return false;
}
2016-05-27 14:26:28 +02:00
}
private bool LoadContentFromLocalDbLocked(bool onStartup)
2016-05-27 14:26:28 +02:00
{
var contentTypes = _serviceContext.ContentTypeService?.GetAll()
.Select(x => _publishedContentTypeFactory.CreateContentType(x));
_contentStore.SetAllContentTypesLocked(contentTypes);
2020-09-15 08:45:40 +02:00
using (_profilingLogger.TraceDuration<PublishedSnapshotService>("Loading content from local cache file"))
{
// beware! at that point the cache is inconsistent,
// assuming we are going to SetAll content items!
2016-05-27 14:26:28 +02:00
return LoadEntitiesFromLocalDbLocked(onStartup, _localContentDb, _contentStore, "content");
}
2016-05-27 14:26:28 +02:00
}
private bool LockAndLoadMedia(Func<bool> action)
{
// see note in LockAndLoadContent
using (_mediaStore?.GetScopedWriteLock(_scopeProvider))
using (var scope = _scopeProvider.CreateScope())
{
scope.ReadLock(Constants.Locks.MediaTree);
var ok = action();
scope.Complete();
return ok;
}
}
private bool LoadMediaFromDatabaseLocked(bool onStartup)
2016-05-27 14:26:28 +02:00
{
// locks & notes: see content
var mediaTypes = _serviceContext.MediaTypeService?.GetAll()
.Select(x => _publishedContentTypeFactory.CreateContentType(x));
_mediaStore.SetAllContentTypesLocked(mediaTypes);
2020-09-15 08:45:40 +02:00
using (_profilingLogger.TraceDuration<PublishedSnapshotService>("Loading media from database"))
{
// beware! at that point the cache is inconsistent,
// assuming we are going to SetAll content items!
_localMediaDb?.Clear();
2016-05-27 14:26:28 +02:00
2020-09-15 08:45:40 +02:00
_logger.LogDebug("Loading media from database...");
2019-08-19 17:18:45 +10:00
// IMPORTANT GetAllMediaSources sorts kits by level + parentId + sortOrder
try
{
var kits = _publishedContentService.GetAllMediaSources();
return onStartup ? _mediaStore.SetAllFastSortedLocked(kits, _config.KitBatchSize, true) : _mediaStore.SetAllLocked(kits, _config.KitBatchSize, true);
}
catch (ThreadAbortException tae)
{
// Caught a ThreadAbortException, most likely from a database timeout.
// If we don't catch it here, the whole local cache can remain locked causing widespread panic (see above comment).
_logger.LogWarning(tae, tae.Message);
}
return false;
}
2016-05-27 14:26:28 +02:00
}
private bool LoadMediaFromLocalDbLocked(bool onStartup)
2016-05-27 14:26:28 +02:00
{
var mediaTypes = _serviceContext.MediaTypeService?.GetAll()
.Select(x => _publishedContentTypeFactory.CreateContentType(x));
_mediaStore.SetAllContentTypesLocked(mediaTypes);
2020-09-15 08:45:40 +02:00
using (_profilingLogger.TraceDuration<PublishedSnapshotService>("Loading media from local cache file"))
{
// beware! at that point the cache is inconsistent,
// assuming we are going to SetAll content items!
2016-05-27 14:26:28 +02:00
return LoadEntitiesFromLocalDbLocked(onStartup, _localMediaDb, _mediaStore, "media");
}
}
private bool LoadEntitiesFromLocalDbLocked(bool onStartup, BPlusTree<int, ContentNodeKit>? localDb, ContentStore store, string entityType)
{
var kits = localDb?.Select(x => x.Value)
.OrderBy(x => x.Node.Level)
2019-08-19 17:18:45 +10:00
.ThenBy(x => x.Node.ParentContentId)
.ThenBy(x => x.Node.SortOrder) // IMPORTANT sort by level + parentId + sortOrder
.ToList();
if (kits is null || kits.Count == 0)
{
// If there's nothing in the local cache file, we should return false? YES even though the site legitately might be empty.
// Is it possible that the cache file is empty but the database is not? YES... (well, it used to be possible)
// * A new file is created when one doesn't exist, this will only be done when MainDom is acquired
// * The new file will be populated as soon as LoadCachesOnStartup is called
// * If the appdomain is going down the moment after MainDom was acquired and we've created an empty cache file,
// then the MainDom release callback is triggered from on a different thread, which will close the file and
// set the cache file reference to null. At this moment, it is possible that the file is closed and the
// reference is set to null BEFORE LoadCachesOnStartup which would mean that the current appdomain would load
// in the in-mem cache via DB calls, BUT this now means that there is an empty cache file which will be
// loaded by the next appdomain and it won't check if it's empty, it just assumes that since the cache
// file is there, that is correct.
// Update: We will still return false here even though the above mentioned race condition has been fixed since we now
// lock the entire operation of creating/populating the cache file with the same lock as releasing/closing the cache file
_logger.LogInformation("Tried to load {entityType} from the local cache file but it was empty.", entityType);
return false;
}
return onStartup ? store.SetAllFastSortedLocked(kits, _config.KitBatchSize, false) : store.SetAllLocked(kits, _config.KitBatchSize, false);
2016-05-27 14:26:28 +02:00
}
private void LockAndLoadDomains()
{
2019-02-22 15:27:22 +01:00
// see note in LockAndLoadContent
using (_domainStore?.GetScopedWriteLock(_scopeProvider))
2019-02-22 15:27:22 +01:00
using (var scope = _scopeProvider.CreateScope())
2016-05-27 14:26:28 +02:00
{
2019-02-22 15:27:22 +01:00
scope.ReadLock(Constants.Locks.Domains);
LoadDomainsLocked();
scope.Complete();
}
2016-05-27 14:26:28 +02:00
}
private void LoadDomainsLocked()
{
var domains = _serviceContext.DomainService?.GetAll(true);
if (domains is not null)
2016-05-27 14:26:28 +02:00
{
foreach (var domain in domains
.Where(x => x.RootContentId.HasValue && x.LanguageIsoCode.IsNullOrWhiteSpace() == false)
.Select(x => new Domain(x.Id, x.DomainName, x.RootContentId!.Value, x.LanguageIsoCode!, x.IsWildcard)))
{
_domainStore.SetLocked(domain.Id, domain);
}
2016-05-27 14:26:28 +02:00
}
}
// note: if the service is not ready, ie _isReady is false, then notifications are ignored
2017-10-31 12:48:24 +01:00
// SetUmbracoVersionStep issues a DistributedCache.Instance.RefreshAll...() call which should cause
2016-05-27 14:26:28 +02:00
// the entire content, media etc caches to reload from database -- and then the app restarts -- however,
// at the time SetUmbracoVersionStep runs, Umbraco is not fully initialized and therefore some property
// value converters, etc are not registered, and rebuilding the NuCache may not work properly.
//
// More details: ApplicationContext.IsConfigured being false, ApplicationEventHandler.ExecuteWhen... is
// called and in most cases events are skipped, so property value converters are not registered or
// removed, so PublishedPropertyType either initializes with the wrong converter, or throws because it
// detects more than one converter for a property type.
//
// It's not an issue for XmlStore - the app restart takes place *after* the install has refreshed the
// cache, and XmlStore just writes a new umbraco.config file upon RefreshAll, so that's OK.
//
// But for NuCache... we cannot rebuild the cache now. So it will NOT work and we are not fixing it,
// because now we should ALWAYS run with the database server messenger, and then the RefreshAll will
// be processed as soon as we are configured and the messenger processes instructions.
// note: notifications for content type and data type changes should be invoked with the
// InMemoryModelFactory, if any, locked and refreshed - see ContentTypeCacheRefresher and
// DataTypeCacheRefresher
public void Notify(ContentCacheRefresher.JsonPayload[] payloads, out bool draftChanged, out bool publishedChanged)
2016-05-27 14:26:28 +02:00
{
EnsureCaches();
2016-05-27 14:26:28 +02:00
2019-03-14 19:48:44 +01:00
using (_contentStore.GetScopedWriteLock(_scopeProvider))
2016-05-27 14:26:28 +02:00
{
NotifyLocked(payloads, out bool draftChanged2, out bool publishedChanged2);
draftChanged = draftChanged2;
publishedChanged = publishedChanged2;
}
2016-05-27 14:26:28 +02:00
if (draftChanged || publishedChanged)
{
CurrentPublishedSnapshot?.Resync();
}
2016-05-27 14:26:28 +02:00
}
// Calling this method means we have a lock on the contentStore (i.e. GetScopedWriteLock)
2016-05-27 14:26:28 +02:00
private void NotifyLocked(IEnumerable<ContentCacheRefresher.JsonPayload> payloads, out bool draftChanged, out bool publishedChanged)
{
publishedChanged = false;
draftChanged = false;
// locks:
// content (and content types) are read-locked while reading content
// contentStore is wlocked (so readable, only no new views)
// and it can be wlocked by 1 thread only at a time
// contentStore is write-locked during changes - see note above, calls to this method are wrapped in contentStore.GetScopedWriteLock
2016-05-27 14:26:28 +02:00
foreach (var payload in payloads)
{
2020-09-15 08:45:40 +02:00
_logger.LogDebug("Notified {ChangeTypes} for content {ContentId}", payload.ChangeTypes, payload.Id);
2016-05-27 14:26:28 +02:00
if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshAll))
{
2017-12-12 15:04:13 +01:00
using (var scope = _scopeProvider.CreateScope())
2016-05-27 14:26:28 +02:00
{
2017-12-12 15:04:13 +01:00
scope.ReadLock(Constants.Locks.ContentTree);
LoadContentFromDatabaseLocked(false);
2017-12-12 15:04:13 +01:00
scope.Complete();
2016-05-27 14:26:28 +02:00
}
draftChanged = publishedChanged = true;
continue;
}
if (payload.ChangeTypes.HasType(TreeChangeTypes.Remove))
{
if (_contentStore.ClearLocked(payload.Id))
2016-05-27 14:26:28 +02:00
draftChanged = publishedChanged = true;
continue;
}
if (payload.ChangeTypes.HasTypesNone(TreeChangeTypes.RefreshNode | TreeChangeTypes.RefreshBranch))
{
// ?!
continue;
}
// TODO: should we do some RV check here? (later)
2016-05-27 14:26:28 +02:00
var capture = payload;
2017-12-12 15:04:13 +01:00
using (var scope = _scopeProvider.CreateScope())
2016-05-27 14:26:28 +02:00
{
2017-12-12 15:04:13 +01:00
scope.ReadLock(Constants.Locks.ContentTree);
2016-05-27 14:26:28 +02:00
if (capture.ChangeTypes.HasType(TreeChangeTypes.RefreshBranch))
{
// ?? should we do some RV check here?
// IMPORTANT GetbranchContentSources sorts kits by level and by sort order
var kits = _publishedContentService.GetBranchContentSources(capture.Id);
_contentStore.SetBranchLocked(capture.Id, kits);
2016-05-27 14:26:28 +02:00
}
else
{
// ?? should we do some RV check here?
var kit = _publishedContentService.GetContentSource(capture.Id);
2016-05-27 14:26:28 +02:00
if (kit.IsEmpty)
{
_contentStore.ClearLocked(capture.Id);
2016-05-27 14:26:28 +02:00
}
else
{
_contentStore.SetLocked(kit);
2016-05-27 14:26:28 +02:00
}
}
2017-12-12 15:04:13 +01:00
scope.Complete();
2016-05-27 14:26:28 +02:00
}
// ?? cannot tell really because we're not doing RV checks
draftChanged = publishedChanged = true;
}
}
/// <inheritdoc />
public void Notify(MediaCacheRefresher.JsonPayload[] payloads, out bool anythingChanged)
2016-05-27 14:26:28 +02:00
{
EnsureCaches();
2016-05-27 14:26:28 +02:00
2019-03-14 19:48:44 +01:00
using (_mediaStore.GetScopedWriteLock(_scopeProvider))
2016-05-27 14:26:28 +02:00
{
NotifyLocked(payloads, out bool anythingChanged2);
anythingChanged = anythingChanged2;
}
2016-05-27 14:26:28 +02:00
if (anythingChanged)
{
CurrentPublishedSnapshot?.Resync();
}
2016-05-27 14:26:28 +02:00
}
private void NotifyLocked(IEnumerable<MediaCacheRefresher.JsonPayload> payloads, out bool anythingChanged)
{
anythingChanged = false;
// locks:
// see notes for content cache refresher
foreach (var payload in payloads)
{
2020-09-15 08:45:40 +02:00
_logger.LogDebug("Notified {ChangeTypes} for media {MediaId}", payload.ChangeTypes, payload.Id);
2016-05-27 14:26:28 +02:00
if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshAll))
{
2017-12-12 15:04:13 +01:00
using (var scope = _scopeProvider.CreateScope())
2016-05-27 14:26:28 +02:00
{
2017-12-12 15:04:13 +01:00
scope.ReadLock(Constants.Locks.MediaTree);
LoadMediaFromDatabaseLocked(false);
2017-12-12 15:04:13 +01:00
scope.Complete();
2016-05-27 14:26:28 +02:00
}
2016-05-27 14:26:28 +02:00
anythingChanged = true;
continue;
}
if (payload.ChangeTypes.HasType(TreeChangeTypes.Remove))
{
if (_mediaStore.ClearLocked(payload.Id))
{
2016-05-27 14:26:28 +02:00
anythingChanged = true;
}
2016-05-27 14:26:28 +02:00
continue;
}
if (payload.ChangeTypes.HasTypesNone(TreeChangeTypes.RefreshNode | TreeChangeTypes.RefreshBranch))
{
// ?!
continue;
}
// TODO: should we do some RV checks here? (later)
2016-05-27 14:26:28 +02:00
var capture = payload;
2017-12-12 15:04:13 +01:00
using (var scope = _scopeProvider.CreateScope())
2016-05-27 14:26:28 +02:00
{
2017-12-12 15:04:13 +01:00
scope.ReadLock(Constants.Locks.MediaTree);
2016-05-27 14:26:28 +02:00
if (capture.ChangeTypes.HasType(TreeChangeTypes.RefreshBranch))
{
// ?? should we do some RV check here?
// IMPORTANT GetbranchContentSources sorts kits by level and by sort order
var kits = _publishedContentService.GetBranchMediaSources(capture.Id);
_mediaStore.SetBranchLocked(capture.Id, kits);
2016-05-27 14:26:28 +02:00
}
else
{
// ?? should we do some RV check here?
var kit = _publishedContentService.GetMediaSource(capture.Id);
2016-05-27 14:26:28 +02:00
if (kit.IsEmpty)
{
_mediaStore.ClearLocked(capture.Id);
2016-05-27 14:26:28 +02:00
}
else
{
_mediaStore.SetLocked(kit);
2016-05-27 14:26:28 +02:00
}
}
2017-12-12 15:04:13 +01:00
scope.Complete();
2016-05-27 14:26:28 +02:00
}
// ?? cannot tell really because we're not doing RV checks
anythingChanged = true;
}
}
/// <inheritdoc />
public void Notify(ContentTypeCacheRefresher.JsonPayload[] payloads)
2016-05-27 14:26:28 +02:00
{
EnsureCaches();
2016-05-27 14:26:28 +02:00
foreach (var payload in payloads)
{
2020-09-15 08:45:40 +02:00
_logger.LogDebug("Notified {ChangeTypes} for {ItemType} {ItemId}", payload.ChangeTypes, payload.ItemType, payload.Id);
}
2016-05-27 14:26:28 +02:00
2017-07-17 17:59:46 +02:00
Notify<IContentType>(_contentStore, payloads, RefreshContentTypesLocked);
Notify<IMediaType>(_mediaStore, payloads, RefreshMediaTypesLocked);
2016-05-27 14:26:28 +02:00
if (_publishedModelFactory.IsLiveFactoryEnabled())
{
// In the case of ModelsMode.InMemoryAuto generated models - we actually need to refresh all of the content and the media
// see https://github.com/umbraco/Umbraco-CMS/issues/5671
// The underlying issue is that in ModelsMode.InMemoryAuto mode the IAutoPublishedModelFactory will re-compile all of the classes/models
// into a new DLL for the application which includes both content types and media types.
// Since the models in the cache are based on these actual classes, all of the objects in the cache need to be updated
// to use the newest version of the class.
2020-04-17 14:56:49 +10:00
// NOTE: Ideally this can be run on background threads here which would prevent blocking the UI
// as is the case when saving a content type. Initially one would think that it won't be any different
2020-04-17 14:56:49 +10:00
// between running this here or in another background thread immediately after with regards to how the
// UI will respond because we already know between calling `WithSafeLiveFactoryReset` to reset the generated models
2020-04-17 14:56:49 +10:00
// and this code here, that many front-end requests could be attempted to be processed. If that is the case, those pages are going to get a
// model binding error and our ModelBindingExceptionFilter is going to to its magic to reload those pages so the end user is none the wiser.
// So whether or not this executes 'here' or on a background thread immediately wouldn't seem to make any difference except that we can return
// execution to the UI sooner.
// BUT!... there is a difference IIRC. There is still execution logic that continues after this call on this thread with the cache refreshers
// and those cache refreshers need to have the up-to-date data since other user cache refreshers will be expecting the data to be 'live'. If
// we ran this on a background thread then those cache refreshers are going to not get 'live' data when they query the content cache which
// they require.
2020-05-04 09:35:48 +02:00
using (_contentStore.GetScopedWriteLock(_scopeProvider))
{
NotifyLocked(new[] { new ContentCacheRefresher.JsonPayload(0, null, TreeChangeTypes.RefreshAll) }, out _, out _);
}
2020-05-04 09:35:48 +02:00
using (_mediaStore.GetScopedWriteLock(_scopeProvider))
{
NotifyLocked(new[] { new MediaCacheRefresher.JsonPayload(0, null, TreeChangeTypes.RefreshAll) }, out _);
}
}
CurrentPublishedSnapshot?.Resync();
2017-07-17 17:59:46 +02:00
}
private void Notify<T>(ContentStore store, ContentTypeCacheRefresher.JsonPayload[] payloads, Action<List<int>?, List<int>?, List<int>?, List<int>?> action)
where T : IContentTypeComposition
2017-07-17 17:59:46 +02:00
{
if (payloads.Length == 0)
{
return; // nothing to do
}
var nameOfT = typeof(T).Name;
2016-05-27 14:26:28 +02:00
List<int>? removedIds = null, refreshedIds = null, otherIds = null, newIds = null;
2016-05-27 14:26:28 +02:00
2017-07-17 17:59:46 +02:00
foreach (var payload in payloads)
{
if (payload.ItemType != nameOfT)
{
continue;
}
2017-07-17 17:59:46 +02:00
if (payload.ChangeTypes.HasType(ContentTypeChangeTypes.Remove))
{
AddToList(ref removedIds, payload.Id);
}
2017-07-17 17:59:46 +02:00
else if (payload.ChangeTypes.HasType(ContentTypeChangeTypes.RefreshMain))
{
AddToList(ref refreshedIds, payload.Id);
}
2017-07-17 17:59:46 +02:00
else if (payload.ChangeTypes.HasType(ContentTypeChangeTypes.RefreshOther))
{
AddToList(ref otherIds, payload.Id);
}
2017-07-17 17:59:46 +02:00
else if (payload.ChangeTypes.HasType(ContentTypeChangeTypes.Create))
{
AddToList(ref newIds, payload.Id);
}
2017-07-17 17:59:46 +02:00
}
2016-05-27 14:26:28 +02:00
if (removedIds.IsCollectionEmpty() && refreshedIds.IsCollectionEmpty() && otherIds.IsCollectionEmpty() && newIds.IsCollectionEmpty())
{
return;
}
2016-05-27 14:26:28 +02:00
2019-03-14 19:48:44 +01:00
using (store.GetScopedWriteLock(_scopeProvider))
2017-07-17 17:59:46 +02:00
{
action(removedIds, refreshedIds, otherIds, newIds);
}
2016-05-27 14:26:28 +02:00
}
public void Notify(DataTypeCacheRefresher.JsonPayload[] payloads)
2016-05-27 14:26:28 +02:00
{
EnsureCaches();
2016-05-27 14:26:28 +02:00
var idsA = payloads.Select(x => x.Id).ToArray();
foreach (var payload in payloads)
{
2020-09-15 08:45:40 +02:00
_logger.LogDebug("Notified {RemovedStatus} for data type {DataTypeId}",
payload.Removed ? "Removed" : "Refreshed",
payload.Id);
}
2016-05-27 14:26:28 +02:00
2019-03-14 19:48:44 +01:00
using (_contentStore.GetScopedWriteLock(_scopeProvider))
using (_mediaStore.GetScopedWriteLock(_scopeProvider))
{
// TODO: need to add a datatype lock
2018-02-09 14:34:28 +01:00
// this is triggering datatypes reload in the factory, and right after we create some
// content types by loading them ... there's a race condition here, which would require
// some locking on datatypes
_publishedContentTypeFactory.NotifyDataTypeChanges(idsA);
2017-12-12 15:04:13 +01:00
using (var scope = _scopeProvider.CreateScope())
{
scope.ReadLock(Constants.Locks.ContentTree);
_contentStore.UpdateDataTypesLocked(idsA, id => CreateContentType(PublishedItemType.Content, id));
2017-12-12 15:04:13 +01:00
scope.Complete();
}
2016-05-27 14:26:28 +02:00
2017-12-12 15:04:13 +01:00
using (var scope = _scopeProvider.CreateScope())
{
scope.ReadLock(Constants.Locks.MediaTree);
_mediaStore.UpdateDataTypesLocked(idsA, id => CreateContentType(PublishedItemType.Media, id));
2017-12-12 15:04:13 +01:00
scope.Complete();
}
2017-12-12 15:04:13 +01:00
}
2016-05-27 14:26:28 +02:00
CurrentPublishedSnapshot?.Resync();
2016-05-27 14:26:28 +02:00
}
public void Notify(DomainCacheRefresher.JsonPayload[] payloads)
2016-05-27 14:26:28 +02:00
{
EnsureCaches();
2016-05-27 14:26:28 +02:00
2019-02-22 15:27:22 +01:00
// see note in LockAndLoadContent
2019-03-14 19:48:44 +01:00
using (_domainStore.GetScopedWriteLock(_scopeProvider))
2016-05-27 14:26:28 +02:00
{
foreach (var payload in payloads)
{
switch (payload.ChangeType)
{
case DomainChangeTypes.RefreshAll:
2017-12-12 15:04:13 +01:00
using (var scope = _scopeProvider.CreateScope())
2016-05-27 14:26:28 +02:00
{
2017-12-12 15:04:13 +01:00
scope.ReadLock(Constants.Locks.Domains);
2016-05-27 14:26:28 +02:00
LoadDomainsLocked();
2017-12-12 15:04:13 +01:00
scope.Complete();
2016-05-27 14:26:28 +02:00
}
break;
case DomainChangeTypes.Remove:
_domainStore.ClearLocked(payload.Id);
2016-05-27 14:26:28 +02:00
break;
case DomainChangeTypes.Refresh:
var domain = _serviceContext.DomainService?.GetById(payload.Id);
2021-08-17 13:10:13 +02:00
if (domain == null)
continue;
if (domain.RootContentId.HasValue == false)
continue; // anomaly
if (domain.LanguageIsoCode.IsNullOrWhiteSpace())
continue; // anomaly
var culture = domain.LanguageIsoCode;
_domainStore.SetLocked(domain.Id, new Domain(domain.Id, domain.DomainName, domain.RootContentId.Value, culture, domain.IsWildcard));
2016-05-27 14:26:28 +02:00
break;
}
}
}
2016-05-27 14:26:28 +02:00
}
// Methods used to prevent allocations of lists
private void AddToList(ref List<int>? list, int val) => GetOrCreateList(ref list).Add(val);
2016-05-27 14:26:28 +02:00
private List<int> GetOrCreateList(ref List<int>? list) => list ?? (list = new List<int>());
2016-05-27 14:26:28 +02:00
private IReadOnlyCollection<IPublishedContentType> CreateContentTypes(PublishedItemType itemType, int[]? ids)
2016-05-27 14:26:28 +02:00
{
2017-10-17 17:43:15 +02:00
// XxxTypeService.GetAll(empty) returns everything!
if (ids is null || ids.Length == 0)
{
return Array.Empty<IPublishedContentType>();
}
2017-10-17 17:43:15 +02:00
IEnumerable<IContentTypeComposition>? contentTypes;
2016-05-27 14:26:28 +02:00
switch (itemType)
{
case PublishedItemType.Content:
contentTypes = _serviceContext.ContentTypeService?.GetAll(ids);
2016-05-27 14:26:28 +02:00
break;
case PublishedItemType.Media:
contentTypes = _serviceContext.MediaTypeService?.GetAll(ids);
2016-05-27 14:26:28 +02:00
break;
case PublishedItemType.Member:
contentTypes = _serviceContext.MemberTypeService?.GetAll(ids);
2016-05-27 14:26:28 +02:00
break;
default:
throw new ArgumentOutOfRangeException(nameof(itemType));
}
if (contentTypes is null)
{
return Array.Empty<IPublishedContentType>();
}
2016-05-27 14:26:28 +02:00
// some may be missing - not checking here
return contentTypes.Select(x => _publishedContentTypeFactory.CreateContentType(x)).ToList();
2016-05-27 14:26:28 +02:00
}
private IPublishedContentType? CreateContentType(PublishedItemType itemType, int id)
2016-05-27 14:26:28 +02:00
{
IContentTypeComposition? contentType;
2016-05-27 14:26:28 +02:00
switch (itemType)
{
case PublishedItemType.Content:
contentType = _serviceContext.ContentTypeService?.Get(id);
2016-05-27 14:26:28 +02:00
break;
case PublishedItemType.Media:
contentType = _serviceContext.MediaTypeService?.Get(id);
2016-05-27 14:26:28 +02:00
break;
case PublishedItemType.Member:
contentType = _serviceContext.MemberTypeService?.Get(id);
2016-05-27 14:26:28 +02:00
break;
default:
throw new ArgumentOutOfRangeException(nameof(itemType));
}
return contentType == null ? null : _publishedContentTypeFactory.CreateContentType(contentType);
2016-05-27 14:26:28 +02:00
}
private void RefreshContentTypesLocked(List<int>? removedIds, List<int>? refreshedIds, List<int>? otherIds, List<int>? newIds)
2016-05-27 14:26:28 +02:00
{
if (removedIds.IsCollectionEmpty() && refreshedIds.IsCollectionEmpty() && otherIds.IsCollectionEmpty() && newIds.IsCollectionEmpty())
{
return;
}
2016-05-27 14:26:28 +02:00
// locks:
// content (and content types) are read-locked while reading content
// contentStore is wlocked (so readable, only no new views)
// and it can be wlocked by 1 thread only at a time
2017-12-12 15:04:13 +01:00
using (var scope = _scopeProvider.CreateScope())
2016-05-27 14:26:28 +02:00
{
2017-12-12 15:04:13 +01:00
scope.ReadLock(Constants.Locks.ContentTypes);
2019-02-21 19:06:41 +01:00
var typesA = refreshedIds.IsCollectionEmpty()
? Array.Empty<IPublishedContentType>()
: CreateContentTypes(PublishedItemType.Content, refreshedIds?.ToArray()).ToArray();
var kits = refreshedIds.IsCollectionEmpty()
? Array.Empty<ContentNodeKit>()
: _publishedContentService.GetTypeContentSources(refreshedIds).ToArray();
2019-02-21 19:06:41 +01:00
_contentStore.UpdateContentTypesLocked(removedIds, typesA, kits);
if (!otherIds.IsCollectionEmpty())
{
_contentStore.UpdateContentTypesLocked(CreateContentTypes(PublishedItemType.Content, otherIds?.ToArray()));
}
if (!newIds.IsCollectionEmpty())
{
_contentStore.NewContentTypesLocked(CreateContentTypes(PublishedItemType.Content, newIds?.ToArray()));
}
2017-12-12 15:04:13 +01:00
scope.Complete();
2016-05-27 14:26:28 +02:00
}
}
private void RefreshMediaTypesLocked(List<int>? removedIds, List<int>? refreshedIds, List<int>? otherIds, List<int>? newIds)
2016-05-27 14:26:28 +02:00
{
if (removedIds.IsCollectionEmpty() && refreshedIds.IsCollectionEmpty() && otherIds.IsCollectionEmpty() && newIds.IsCollectionEmpty())
{
return;
}
2016-05-27 14:26:28 +02:00
// locks:
// media (and content types) are read-locked while reading media
// mediaStore is wlocked (so readable, only no new views)
// and it can be wlocked by 1 thread only at a time
2017-12-12 15:04:13 +01:00
using (var scope = _scopeProvider.CreateScope())
2016-05-27 14:26:28 +02:00
{
2017-12-12 15:04:13 +01:00
scope.ReadLock(Constants.Locks.MediaTypes);
2019-02-21 19:06:41 +01:00
var typesA = refreshedIds == null
? Array.Empty<IPublishedContentType>()
: CreateContentTypes(PublishedItemType.Media, refreshedIds.ToArray()).ToArray();
var kits = refreshedIds == null
? Array.Empty<ContentNodeKit>()
: _publishedContentService.GetTypeMediaSources(refreshedIds).ToArray();
2019-02-21 19:06:41 +01:00
_mediaStore.UpdateContentTypesLocked(removedIds, typesA, kits);
if (!otherIds.IsCollectionEmpty())
{
_mediaStore.UpdateContentTypesLocked(CreateContentTypes(PublishedItemType.Media, otherIds?.ToArray()).ToArray());
}
if (!newIds.IsCollectionEmpty())
{
_mediaStore.NewContentTypesLocked(CreateContentTypes(PublishedItemType.Media, newIds?.ToArray()).ToArray());
}
2017-12-12 15:04:13 +01:00
scope.Complete();
2016-05-27 14:26:28 +02:00
}
}
2022-03-29 13:44:21 +02:00
public IPublishedSnapshot CreatePublishedSnapshot(string? previewToken)
2016-05-27 14:26:28 +02:00
{
EnsureCaches();
2016-05-27 14:26:28 +02:00
// no cache, no joy
if (Volatile.Read(ref _isReady) == false)
{
2017-10-31 12:48:24 +01:00
throw new InvalidOperationException("The published snapshot service has not properly initialized.");
}
2016-05-27 14:26:28 +02:00
var preview = previewToken.IsNullOrWhiteSpace() == false;
2018-04-27 11:38:50 +10:00
return new PublishedSnapshot(this, preview);
2016-05-27 14:26:28 +02:00
}
// gets a new set of elements
// always creates a new set of elements,
// even though the underlying elements may not change (store snapshots)
2018-04-27 11:38:50 +10:00
public PublishedSnapshot.PublishedSnapshotElements GetElements(bool previewDefault)
2016-05-27 14:26:28 +02:00
{
EnsureCaches();
2019-01-18 08:29:16 +01:00
// note: using ObjectCacheAppCache for elements and snapshot caches
2016-05-27 14:26:28 +02:00
// is not recommended because it creates an inner MemoryCache which is a heavy
2019-01-18 08:29:16 +01:00
// thing - better use a dictionary-based cache which "just" creates a concurrent
2016-05-27 14:26:28 +02:00
// dictionary
2019-01-18 08:29:16 +01:00
// for snapshot cache, DictionaryAppCache MAY be OK but it is not thread-safe,
2016-05-27 14:26:28 +02:00
// nothing like that...
2019-01-18 08:29:16 +01:00
// for elements cache, DictionaryAppCache is a No-No, use something better.
// ie FastDictionaryAppCache (thread safe and all)
2017-07-12 14:09:31 +02:00
ContentStore.Snapshot contentSnap, mediaSnap;
2016-05-27 14:26:28 +02:00
SnapDictionary<int, Domain>.Snapshot domainSnap;
IAppCache? elementsCache;
2020-01-06 21:14:46 +11:00
// Here we are reading/writing to shared objects so we need to lock (can't be _storesLock which manages the actual nucache files
// and would result in a deadlock). Even though we are locking around underlying readlocks (within CreateSnapshot) it's because
// we need to ensure that the result of contentSnap.Gen (etc) and the re-assignment of these values and _elements cache
// are done atomically.
lock (_elementsLock)
2016-05-27 14:26:28 +02:00
{
IScopeContext? scopeContext = _scopeProvider.Context;
2017-07-18 19:24:27 +02:00
if (scopeContext == null)
{
contentSnap = _contentStore.CreateSnapshot();
mediaSnap = _mediaStore.CreateSnapshot();
domainSnap = _domainStore.CreateSnapshot();
2017-10-31 12:48:24 +01:00
elementsCache = _elementsCache;
2017-07-18 19:24:27 +02:00
}
else
{
contentSnap = _contentStore.LiveSnapshot;
mediaSnap = _mediaStore.LiveSnapshot;
domainSnap = _domainStore.Test.LiveSnapshot;
2017-10-31 12:48:24 +01:00
elementsCache = _elementsCache;
2017-07-18 19:24:27 +02:00
2017-07-19 19:59:46 +02:00
// this is tricky
// we are returning elements composed from live snapshots, which we need to replace
// with actual snapshots when the context is gone - but when the action runs, there
// still is a context - so we cannot get elements - just resync = nulls the current
// elements
// just need to make sure nothing gets elements in another enlisted action... so using
// a MaxValue to make sure this one runs last, and it should be ok
2020-01-03 12:39:17 +11:00
2017-10-31 12:48:24 +01:00
scopeContext.Enlist("Umbraco.Web.PublishedCache.NuCache.PublishedSnapshotService.Resync", () => this, (completed, svc) =>
2017-07-18 19:24:27 +02:00
{
svc?.CurrentPublishedSnapshot?.Resync();
2017-07-19 19:59:46 +02:00
}, int.MaxValue);
2017-07-18 19:24:27 +02:00
}
2016-05-27 14:26:28 +02:00
// create a new snapshot cache if snapshots are different gens
2017-10-31 12:48:24 +01:00
if (contentSnap.Gen != _contentGen || mediaSnap.Gen != _mediaGen || domainSnap.Gen != _domainGen || _elementsCache == null)
2016-05-27 14:26:28 +02:00
{
_contentGen = contentSnap.Gen;
_mediaGen = mediaSnap.Gen;
_domainGen = domainSnap.Gen;
elementsCache = _elementsCache = new FastDictionaryAppCache();
2016-05-27 14:26:28 +02:00
}
}
2019-01-18 08:29:16 +01:00
var snapshotCache = new DictionaryAppCache();
2017-07-18 19:24:27 +02:00
var memberTypeCache = new PublishedContentTypeCache(null, null, _serviceContext.MemberTypeService, _publishedContentTypeFactory, _loggerFactory.CreateLogger<PublishedContentTypeCache>());
2016-05-27 14:26:28 +02:00
2018-04-30 21:29:49 +02:00
var defaultCulture = _defaultCultureAccessor.DefaultCulture;
2018-04-26 16:03:08 +02:00
var domainCache = new DomainCache(domainSnap, defaultCulture);
2016-05-27 14:26:28 +02:00
2018-04-27 11:38:50 +10:00
return new PublishedSnapshot.PublishedSnapshotElements
2016-05-27 14:26:28 +02:00
{
ContentCache = new ContentCache(previewDefault, contentSnap, snapshotCache, elementsCache, domainCache, Options.Create(_globalSettings), _variationContextAccessor),
MediaCache = new MediaCache(previewDefault, mediaSnap, _variationContextAccessor),
Published members cleanup (#10159) * Getting new netcore PublicAccessChecker in place * Adds full test coverage for PublicAccessChecker * remove PublicAccessComposer * adjust namespaces, ensure RoleManager works, separate public access controller, reduce content controller * Implements the required methods on IMemberManager, removes old migrated code * Updates routing to be able to re-route, Fixes middleware ordering ensuring endpoints are last, refactors pipeline options, adds public access middleware, ensures public access follows all hops * adds note * adds note * Cleans up ext methods, ensures that members identity is added on both front-end and back ends. updates how UmbracoApplicationBuilder works in that it explicitly starts endpoints at the time of calling. * Changes name to IUmbracoEndpointBuilder * adds note * Fixing tests, fixing error describers so there's 2x one for back office, one for members, fixes TryConvertTo, fixes login redirect * fixing build * Updates user manager to correctly validate password hashing and injects the IBackOfficeUserPasswordChecker * Merges PR * Fixes up build and notes * Implements security stamp and email confirmed for members, cleans up a bunch of repo/service level member groups stuff, shares user store code between members and users and fixes the user identity object so we arent' tracking both groups and roles. * Security stamp for members is now working * Fixes keepalive, fixes PublicAccessMiddleware to not throw, updates startup code to be more clear and removes magic that registers middleware. * adds note * removes unused filter, fixes build * fixes WebPath and tests * Looks up entities in one query * remove usings * Fix test, remove stylesheet * Set status code before we write to response to avoid error * Ensures that users and members are validated when logging in. Shares more code between users and members. * merge changes * oops * Reducing and removing published member cache * Fixes RepositoryCacheKeys to ensure the keys are normalized * oops didn't mean to commit this * Fix casing issues with caching, stop boxing value types for all cache operations, stop re-creating string keys in DefaultRepositoryCachePolicy * oops didn't mean to comit this * bah, far out this keeps getting recommitted. sorry * cannot inject IPublishedMemberCache and cannot have IPublishedMember * splits out files, fixes build * fix tests * removes membership provider classes * removes membership provider classes * updates the identity map definition * reverts commented out lines * reverts commented out lines Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2021-04-22 21:21:43 +10:00
MemberCache = new MemberCache(previewDefault, memberTypeCache, _publishedSnapshotAccessor, _variationContextAccessor, _publishedModelFactory),
2016-05-27 14:26:28 +02:00
DomainCache = domainCache,
2017-10-31 12:48:24 +01:00
SnapshotCache = snapshotCache,
ElementsCache = elementsCache
2016-05-27 14:26:28 +02:00
};
}
/// <inheritdoc />
public void Rebuild(
IReadOnlyCollection<int>? contentTypeIds = null,
IReadOnlyCollection<int>? mediaTypeIds = null,
IReadOnlyCollection<int>? memberTypeIds = null)
Merge commit '94d525d88f713b36419f28bfda4d82ee68637d83' into v9/dev # Conflicts: # build/NuSpecs/UmbracoCms.Web.nuspec # src/Umbraco.Core/Composing/Current.cs # src/Umbraco.Core/Persistence/NPocoDatabaseExtensions-Bulk.cs # src/Umbraco.Core/Runtime/CoreRuntime.cs # src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs # src/Umbraco.Infrastructure/Persistence/NPocoDatabaseExtensions.cs # src/Umbraco.Infrastructure/Persistence/UmbracoDatabase.cs # src/Umbraco.Persistence.SqlCe/SqlCeSyntaxProvider.cs # src/Umbraco.PublishedCache.NuCache/DataSource/BTree.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentCacheDataModel.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentCacheDataSerializationResult.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentCacheDataSerializerEntityType.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentData.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentNestedData.cs # src/Umbraco.PublishedCache.NuCache/DataSource/CultureVariation.cs # src/Umbraco.PublishedCache.NuCache/DataSource/IContentCacheDataSerializer.cs # src/Umbraco.PublishedCache.NuCache/DataSource/IContentCacheDataSerializerFactory.cs # src/Umbraco.PublishedCache.NuCache/DataSource/IDictionaryOfPropertyDataSerializer.cs # src/Umbraco.PublishedCache.NuCache/DataSource/JsonContentNestedDataSerializer.cs # src/Umbraco.PublishedCache.NuCache/DataSource/JsonContentNestedDataSerializerFactory.cs # src/Umbraco.PublishedCache.NuCache/DataSource/LazyCompressedString.cs # src/Umbraco.PublishedCache.NuCache/DataSource/MsgPackContentNestedDataSerializer.cs # src/Umbraco.PublishedCache.NuCache/DataSource/MsgPackContentNestedDataSerializerFactory.cs # src/Umbraco.PublishedCache.NuCache/DataSource/PropertyData.cs # src/Umbraco.PublishedCache.NuCache/NuCacheSerializerComponent.cs # src/Umbraco.PublishedCache.NuCache/NuCacheSerializerComposer.cs # src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentTypeServiceVariantsTests.cs # src/Umbraco.Tests/App.config # src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs # src/Umbraco.Tests/PublishedContent/NuCacheTests.cs # src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs # src/Umbraco.Web.UI.NetCore/umbraco/config/lang/da.xml # src/Umbraco.Web.UI/web.Template.Debug.config # src/Umbraco.Web.UI/web.Template.config # src/Umbraco.Web/Composing/ModuleInjector.cs # src/Umbraco.Web/Editors/NuCacheStatusController.cs # src/Umbraco.Web/PublishedCache/NuCache/DataSource/ContentNestedData.cs # src/Umbraco.Web/PublishedCache/NuCache/DataSource/DatabaseDataSource.cs # src/Umbraco.Web/PublishedCache/NuCache/NuCacheComposer.cs # src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs # src/Umbraco.Web/Runtime/WebRuntime.cs
2021-06-24 09:43:57 -06:00
=> _publishedContentService.Rebuild(contentTypeIds, mediaTypeIds, memberTypeIds);
2016-05-27 14:26:28 +02:00
public async Task CollectAsync()
2016-05-27 14:26:28 +02:00
{
EnsureCaches();
await _contentStore.CollectAsync();
await _mediaStore.CollectAsync();
2016-05-27 14:26:28 +02:00
}
internal ContentStore GetContentStore()
{
EnsureCaches();
return _contentStore;
}
internal ContentStore? GetMediaStore()
{
EnsureCaches();
return _mediaStore;
}
/// <inheritdoc/>
public void Dispose()
{ }
2016-05-27 14:26:28 +02:00
}
}