Merge remote-tracking branch 'origin/netcore/dev' into netcore/feature/fileservice-events

# Conflicts:
#	src/Umbraco.Infrastructure/Cache/DistributedCacheBinder_Handlers.cs
#	src/Umbraco.Infrastructure/Compose/NotificationsComposer.cs
#	src/Umbraco.Tests.Integration/Cache/DistributedCacheBinderTests.cs
This commit is contained in:
Bjarke Berg
2021-04-07 14:34:34 +02:00
53 changed files with 1280 additions and 742 deletions

View File

@@ -37,7 +37,13 @@ namespace Umbraco.Cms.Core.Cache
INotificationHandler<TemplateDeletedNotification>,
INotificationHandler<TemplateSavedNotification>,
INotificationHandler<DataTypeDeletedNotification>,
INotificationHandler<DataTypeSavedNotification>
INotificationHandler<DataTypeSavedNotification>,
INotificationHandler<RelationTypeDeletedNotification>,
INotificationHandler<RelationTypeSavedNotification>,
INotificationHandler<DomainDeletedNotification>,
INotificationHandler<DomainSavedNotification>,
INotificationHandler<MacroSavedNotification>,
INotificationHandler<MacroDeletedNotification>
{
private List<Action> _unbinders;
@@ -68,12 +74,6 @@ namespace Umbraco.Cms.Core.Cache
_logger.LogInformation("Initializing Umbraco internal event handlers for cache refreshing.");
// bind to domain events
Bind(() => DomainService.Saved += DomainService_Saved,
() => DomainService.Saved -= DomainService_Saved);
Bind(() => DomainService.Deleted += DomainService_Deleted,
() => DomainService.Deleted -= DomainService_Deleted);
// bind to content type events
Bind(() => ContentTypeService.Changed += ContentTypeService_Changed,
() => ContentTypeService.Changed -= ContentTypeService_Changed);
@@ -82,12 +82,6 @@ namespace Umbraco.Cms.Core.Cache
Bind(() => MemberTypeService.Changed += MemberTypeService_Changed,
() => MemberTypeService.Changed -= MemberTypeService_Changed);
// bind to macro events
Bind(() => MacroService.Saved += MacroService_Saved,
() => MacroService.Saved -= MacroService_Saved);
Bind(() => MacroService.Deleted += MacroService_Deleted,
() => MacroService.Deleted -= MacroService_Deleted);
// bind to media events - handles all media changes
Bind(() => MediaService.TreeChanged += MediaService_TreeChanged,
() => MediaService.TreeChanged -= MediaService_TreeChanged);
@@ -101,12 +95,6 @@ namespace Umbraco.Cms.Core.Cache
// () => ContentService.SavedBlueprint -= ContentService_SavedBlueprint);
//Bind(() => ContentService.DeletedBlueprint += ContentService_DeletedBlueprint,
// () => ContentService.DeletedBlueprint -= ContentService_DeletedBlueprint);
// bind to relation type events
Bind(() => RelationService.SavedRelationType += RelationService_SavedRelationType,
() => RelationService.SavedRelationType -= RelationService_SavedRelationType);
Bind(() => RelationService.DeletedRelationType += RelationService_DeletedRelationType,
() => RelationService.DeletedRelationType -= RelationService_DeletedRelationType);
}
#region PublicAccessService
@@ -197,16 +185,20 @@ namespace Umbraco.Cms.Core.Cache
#region DomainService
private void DomainService_Saved(IDomainService sender, SaveEventArgs<IDomain> e)
public void Handle(DomainSavedNotification notification)
{
foreach (var entity in e.SavedEntities)
foreach (IDomain entity in notification.SavedEntities)
{
_distributedCache.RefreshDomainCache(entity);
}
}
private void DomainService_Deleted(IDomainService sender, DeleteEventArgs<IDomain> e)
public void Handle(DomainDeletedNotification notification)
{
foreach (var entity in e.DeletedEntities)
foreach (IDomain entity in notification.DeletedEntities)
{
_distributedCache.RemoveDomainCache(entity);
}
}
#endregion
@@ -332,16 +324,20 @@ namespace Umbraco.Cms.Core.Cache
#region MacroService
private void MacroService_Deleted(IMacroService sender, DeleteEventArgs<IMacro> e)
public void Handle(MacroDeletedNotification notification)
{
foreach (var entity in e.DeletedEntities)
foreach (IMacro entity in notification.DeletedEntities)
{
_distributedCache.RemoveMacroCache(entity);
}
}
private void MacroService_Saved(IMacroService sender, SaveEventArgs<IMacro> e)
public void Handle(MacroSavedNotification notification)
{
foreach (var entity in e.SavedEntities)
foreach (IMacro entity in notification.SavedEntities)
{
_distributedCache.RefreshMacroCache(entity);
}
}
#endregion
@@ -399,18 +395,22 @@ namespace Umbraco.Cms.Core.Cache
#region RelationType
private void RelationService_SavedRelationType(IRelationService sender, SaveEventArgs<IRelationType> args)
public void Handle(RelationTypeSavedNotification notification)
{
var dc = _distributedCache;
foreach (var e in args.SavedEntities)
dc.RefreshRelationTypeCache(e.Id);
DistributedCache dc = _distributedCache;
foreach (IRelationType entity in notification.SavedEntities)
{
dc.RefreshRelationTypeCache(entity.Id);
}
}
private void RelationService_DeletedRelationType(IRelationService sender, DeleteEventArgs<IRelationType> args)
public void Handle(RelationTypeDeletedNotification notification)
{
var dc = _distributedCache;
foreach (var e in args.DeletedEntities)
dc.RemoveRelationTypeCache(e.Id);
DistributedCache dc = _distributedCache;
foreach (IRelationType entity in notification.DeletedEntities)
{
dc.RemoveRelationTypeCache(entity.Id);
}
}
#endregion