V15: Refresh caches on load balanced environments (#17296)
* Move DocumentCacheService * Add clear all documentws from memory cache * Fix RedirectTracker * Implement refresh node/branch/all/delete * Only update databasecache in RefreshContentAsync * Fix tests * Skip blueprints in cache * Clear caches when contenttype is updated * Clear cache on data type update * Refresh media * Only update memory cache from refreshers * Fix imports * Add named options * Use cache entry settings in media * Obsolete nucache settings --------- Co-authored-by: Bjarke Berg <mail@bergmania.dk>
This commit is contained in:
@@ -20,6 +20,7 @@ public sealed class ContentCacheRefresher : PayloadCacheRefresherBase<ContentCac
|
||||
private readonly IDocumentNavigationQueryService _documentNavigationQueryService;
|
||||
private readonly IDocumentNavigationManagementService _documentNavigationManagementService;
|
||||
private readonly IContentService _contentService;
|
||||
private readonly IDocumentCacheService _documentCacheService;
|
||||
private readonly IPublishStatusManagementService _publishStatusManagementService;
|
||||
private readonly IIdKeyMap _idKeyMap;
|
||||
|
||||
@@ -35,7 +36,8 @@ public sealed class ContentCacheRefresher : PayloadCacheRefresherBase<ContentCac
|
||||
IDocumentNavigationQueryService documentNavigationQueryService,
|
||||
IDocumentNavigationManagementService documentNavigationManagementService,
|
||||
IContentService contentService,
|
||||
IPublishStatusManagementService publishStatusManagementService)
|
||||
IPublishStatusManagementService publishStatusManagementService,
|
||||
IDocumentCacheService documentCacheService)
|
||||
: base(appCaches, serializer, eventAggregator, factory)
|
||||
{
|
||||
_idKeyMap = idKeyMap;
|
||||
@@ -45,6 +47,7 @@ public sealed class ContentCacheRefresher : PayloadCacheRefresherBase<ContentCac
|
||||
_documentNavigationQueryService = documentNavigationQueryService;
|
||||
_documentNavigationManagementService = documentNavigationManagementService;
|
||||
_contentService = contentService;
|
||||
_documentCacheService = documentCacheService;
|
||||
_publishStatusManagementService = publishStatusManagementService;
|
||||
}
|
||||
|
||||
@@ -107,6 +110,7 @@ public sealed class ContentCacheRefresher : PayloadCacheRefresherBase<ContentCac
|
||||
}
|
||||
|
||||
|
||||
HandleMemoryCache(payload);
|
||||
HandleRouting(payload);
|
||||
|
||||
HandleNavigation(payload);
|
||||
@@ -143,6 +147,45 @@ public sealed class ContentCacheRefresher : PayloadCacheRefresherBase<ContentCac
|
||||
base.Refresh(payloads);
|
||||
}
|
||||
|
||||
private void HandleMemoryCache(JsonPayload payload)
|
||||
{
|
||||
Guid key = payload.Key ?? _idKeyMap.GetKeyForId(payload.Id, UmbracoObjectTypes.Document).Result;
|
||||
|
||||
if (payload.Blueprint)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshNode))
|
||||
{
|
||||
_documentCacheService.RefreshMemoryCacheAsync(key).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshBranch))
|
||||
{
|
||||
if (_documentNavigationQueryService.TryGetDescendantsKeys(key, out IEnumerable<Guid> descendantsKeys))
|
||||
{
|
||||
var branchKeys = descendantsKeys.ToList();
|
||||
branchKeys.Add(key);
|
||||
|
||||
foreach (Guid branchKey in branchKeys)
|
||||
{
|
||||
_documentCacheService.RefreshMemoryCacheAsync(branchKey).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshAll))
|
||||
{
|
||||
_documentCacheService.ClearMemoryCacheAsync(CancellationToken.None).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
if (payload.ChangeTypes.HasType(TreeChangeTypes.Remove))
|
||||
{
|
||||
_documentCacheService.RemoveFromMemoryCacheAsync(key).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleNavigation(JsonPayload payload)
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user