Added start-up logging of document URL caching (#19538)

Added startup logging of document URL caching.
This commit is contained in:
Andy Butland
2025-06-12 22:20:44 +02:00
committed by GitHub
parent da9c6e24ce
commit 9d11c76ea1

View File

@@ -141,14 +141,18 @@ public class DocumentUrlService : IDocumentUrlService
using ICoreScope scope = _coreScopeProvider.CreateCoreScope();
if (ShouldRebuildUrls())
{
_logger.LogInformation("Rebuilding all URLs.");
_logger.LogInformation("Rebuilding all document URLs.");
await RebuildAllUrlsAsync();
}
_logger.LogInformation("Caching document URLs.");
IEnumerable<PublishedDocumentUrlSegment> publishedDocumentUrlSegments = _documentUrlRepository.GetAll();
IEnumerable<ILanguage> languages = await _languageService.GetAllAsync();
var languageIdToIsoCode = languages.ToDictionary(x => x.Id, x => x.IsoCode);
int numberOfCachedUrls = 0;
foreach (PublishedDocumentUrlSegments publishedDocumentUrlSegment in ConvertToCacheModel(publishedDocumentUrlSegments))
{
if (cancellationToken.IsCancellationRequested)
@@ -159,9 +163,12 @@ public class DocumentUrlService : IDocumentUrlService
if (languageIdToIsoCode.TryGetValue(publishedDocumentUrlSegment.LanguageId, out var isoCode))
{
UpdateCache(_coreScopeProvider.Context!, publishedDocumentUrlSegment, isoCode);
numberOfCachedUrls++;
}
}
_logger.LogInformation("Cached {NumberOfUrls} document URLs.", numberOfCachedUrls);
_isInitialized = true;
scope.Complete();
}