2021-03-01 13:10:37 +01:00
|
|
|
// Copyright (c) Umbraco.
|
2021-02-12 10:13:56 +01:00
|
|
|
// See LICENSE for more details.
|
|
|
|
|
|
|
|
|
|
using System;
|
2017-05-12 14:49:44 +02:00
|
|
|
using System.Collections.Generic;
|
2019-01-02 15:24:05 +01:00
|
|
|
using System.Linq;
|
2020-09-21 09:52:58 +02:00
|
|
|
using Microsoft.Extensions.Logging;
|
2021-02-09 10:22:42 +01:00
|
|
|
using Umbraco.Cms.Core.Events;
|
|
|
|
|
using Umbraco.Cms.Core.Models;
|
|
|
|
|
using Umbraco.Cms.Core.Models.Membership;
|
|
|
|
|
using Umbraco.Cms.Core.Services;
|
|
|
|
|
using Umbraco.Cms.Core.Services.Changes;
|
2021-02-23 12:24:51 +01:00
|
|
|
using Umbraco.Cms.Core.Services.Implement;
|
2021-03-25 14:51:00 +01:00
|
|
|
using Umbraco.Cms.Infrastructure.Services.Notifications;
|
2021-02-12 10:13:56 +01:00
|
|
|
using Umbraco.Extensions;
|
2016-09-08 18:43:58 +02:00
|
|
|
|
2021-02-12 10:13:56 +01:00
|
|
|
namespace Umbraco.Cms.Core.Cache
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
2019-01-02 15:24:05 +01:00
|
|
|
/// Default <see cref="IDistributedCacheBinder"/> implementation.
|
2016-09-08 18:43:58 +02:00
|
|
|
/// </summary>
|
2021-03-25 14:51:00 +01:00
|
|
|
public partial class DistributedCacheBinder :
|
|
|
|
|
INotificationHandler<DictionaryItemDeletedNotification>,
|
|
|
|
|
INotificationHandler<DictionaryItemSavedNotification>,
|
|
|
|
|
INotificationHandler<LanguageSavedNotification>,
|
2021-03-26 18:47:06 +01:00
|
|
|
INotificationHandler<LanguageDeletedNotification>,
|
2021-03-29 10:42:42 +02:00
|
|
|
INotificationHandler<MemberSavedNotification>,
|
|
|
|
|
INotificationHandler<MemberDeletedNotification>,
|
|
|
|
|
INotificationHandler<PublicAccessEntrySavedNotification>,
|
|
|
|
|
INotificationHandler<PublicAccessEntryDeletedNotification>,
|
|
|
|
|
INotificationHandler<UserSavedNotification>,
|
|
|
|
|
INotificationHandler<UserDeletedNotification>,
|
|
|
|
|
INotificationHandler<UserGroupWithUsersSavedNotification>,
|
2021-03-29 13:46:06 +02:00
|
|
|
INotificationHandler<UserGroupDeletedNotification>,
|
2021-03-26 18:47:06 +01:00
|
|
|
INotificationHandler<MemberGroupDeletedNotification>,
|
2021-03-30 12:14:32 +02:00
|
|
|
INotificationHandler<MemberGroupSavedNotification>,
|
2021-03-30 14:01:37 +02:00
|
|
|
INotificationHandler<TemplateDeletedNotification>,
|
2021-03-31 09:51:08 +02:00
|
|
|
INotificationHandler<TemplateSavedNotification>,
|
2021-03-30 09:25:34 +01:00
|
|
|
INotificationHandler<DataTypeDeletedNotification>,
|
2021-03-31 11:52:36 +02:00
|
|
|
INotificationHandler<DataTypeSavedNotification>,
|
|
|
|
|
INotificationHandler<RelationTypeDeletedNotification>,
|
2021-04-07 13:33:46 +02:00
|
|
|
INotificationHandler<RelationTypeSavedNotification>,
|
2021-03-31 13:26:31 +02:00
|
|
|
INotificationHandler<DomainDeletedNotification>,
|
2021-04-07 12:45:18 +02:00
|
|
|
INotificationHandler<DomainSavedNotification>,
|
2021-03-29 15:09:26 +02:00
|
|
|
INotificationHandler<MacroSavedNotification>,
|
|
|
|
|
INotificationHandler<MacroDeletedNotification>
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2017-05-12 14:49:44 +02:00
|
|
|
private List<Action> _unbinders;
|
|
|
|
|
|
2019-01-02 15:24:05 +01:00
|
|
|
private void Bind(Action binder, Action unbinder)
|
|
|
|
|
{
|
|
|
|
|
// bind now
|
|
|
|
|
binder();
|
|
|
|
|
|
|
|
|
|
// and register unbinder for later, if needed
|
|
|
|
|
_unbinders?.Add(unbinder);
|
|
|
|
|
}
|
2017-05-12 14:49:44 +02:00
|
|
|
|
2019-01-02 15:24:05 +01:00
|
|
|
/// <inheritdoc />
|
|
|
|
|
public void UnbindEvents()
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2019-01-02 15:24:05 +01:00
|
|
|
if (_unbinders == null)
|
|
|
|
|
throw new NotSupportedException();
|
|
|
|
|
foreach (var unbinder in _unbinders)
|
|
|
|
|
unbinder();
|
|
|
|
|
_unbinders = null;
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
2019-01-02 15:24:05 +01:00
|
|
|
/// <inheritdoc />
|
|
|
|
|
public void BindEvents(bool supportUnbinding = false)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2019-01-02 15:24:05 +01:00
|
|
|
if (supportUnbinding)
|
|
|
|
|
_unbinders = new List<Action>();
|
2017-05-12 14:49:44 +02:00
|
|
|
|
2020-09-15 08:45:40 +02:00
|
|
|
_logger.LogInformation("Initializing Umbraco internal event handlers for cache refreshing.");
|
2017-07-11 19:13:45 +02:00
|
|
|
|
2016-09-08 18:43:58 +02:00
|
|
|
// bind to content type events
|
2017-05-12 14:49:44 +02:00
|
|
|
Bind(() => ContentTypeService.Changed += ContentTypeService_Changed,
|
|
|
|
|
() => ContentTypeService.Changed -= ContentTypeService_Changed);
|
2017-06-23 18:54:42 +02:00
|
|
|
Bind(() => MediaTypeService.Changed += MediaTypeService_Changed,
|
|
|
|
|
() => MediaTypeService.Changed -= MediaTypeService_Changed);
|
|
|
|
|
Bind(() => MemberTypeService.Changed += MemberTypeService_Changed,
|
|
|
|
|
() => MemberTypeService.Changed -= MemberTypeService_Changed);
|
2016-09-08 18:43:58 +02:00
|
|
|
|
2017-05-12 14:49:44 +02:00
|
|
|
// bind to media events - handles all media changes
|
2019-03-04 16:38:47 +01:00
|
|
|
Bind(() => MediaService.TreeChanged += MediaService_TreeChanged,
|
|
|
|
|
() => MediaService.TreeChanged -= MediaService_TreeChanged);
|
2016-09-08 18:43:58 +02:00
|
|
|
|
|
|
|
|
// bind to content events
|
2019-01-14 08:05:37 +01:00
|
|
|
Bind(() => ContentService.TreeChanged += ContentService_TreeChanged,// handles all content changes
|
|
|
|
|
() => ContentService.TreeChanged -= ContentService_TreeChanged);
|
2016-09-08 18:43:58 +02:00
|
|
|
|
2017-09-14 11:41:46 +02:00
|
|
|
// TreeChanged should also deal with this
|
|
|
|
|
//Bind(() => ContentService.SavedBlueprint += ContentService_SavedBlueprint,
|
|
|
|
|
// () => ContentService.SavedBlueprint -= ContentService_SavedBlueprint);
|
|
|
|
|
//Bind(() => ContentService.DeletedBlueprint += ContentService_DeletedBlueprint,
|
|
|
|
|
// () => ContentService.DeletedBlueprint -= ContentService_DeletedBlueprint);
|
2017-05-12 14:49:44 +02:00
|
|
|
}
|
2016-09-08 18:43:58 +02:00
|
|
|
|
|
|
|
|
#region PublicAccessService
|
|
|
|
|
|
2021-03-29 10:42:42 +02:00
|
|
|
public void Handle(PublicAccessEntrySavedNotification notification)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2017-07-11 19:13:45 +02:00
|
|
|
_distributedCache.RefreshPublicAccess();
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
2021-03-29 10:42:42 +02:00
|
|
|
public void Handle(PublicAccessEntryDeletedNotification notification)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2017-07-11 19:13:45 +02:00
|
|
|
_distributedCache.RefreshPublicAccess();
|
2021-03-29 10:42:42 +02:00
|
|
|
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ContentService
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Handles cache refreshing for when content is copied
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// When an entity is copied new permissions may be assigned to it based on it's parent, if that is the
|
|
|
|
|
/// case then we need to clear all user permissions cache.
|
|
|
|
|
/// </remarks>
|
2017-07-11 19:13:45 +02:00
|
|
|
private void ContentService_Copied(IContentService sender, CopyEventArgs<IContent> e)
|
2019-01-02 15:24:05 +01:00
|
|
|
{
|
|
|
|
|
}
|
2016-09-08 18:43:58 +02:00
|
|
|
|
2019-01-14 08:05:37 +01:00
|
|
|
private void ContentService_TreeChanged(IContentService sender, TreeChange<IContent>.EventArgs args)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2017-07-11 19:13:45 +02:00
|
|
|
_distributedCache.RefreshContentCache(args.Changes.ToArray());
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
2017-09-14 11:41:46 +02:00
|
|
|
//private void ContentService_SavedBlueprint(IContentService sender, SaveEventArgs<IContent> e)
|
|
|
|
|
//{
|
|
|
|
|
// _distributedCache.RefreshUnpublishedPageCache(e.SavedEntities.ToArray());
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//private void ContentService_DeletedBlueprint(IContentService sender, DeleteEventArgs<IContent> e)
|
|
|
|
|
//{
|
|
|
|
|
// _distributedCache.RemoveUnpublishedPageCache(e.DeletedEntities.ToArray());
|
|
|
|
|
//}
|
|
|
|
|
|
2016-09-08 18:43:58 +02:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region LocalizationService / Dictionary
|
2021-03-25 14:51:00 +01:00
|
|
|
public void Handle(DictionaryItemSavedNotification notification)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2021-03-25 14:51:00 +01:00
|
|
|
foreach (IDictionaryItem entity in notification.SavedEntities)
|
|
|
|
|
{
|
2017-07-11 19:13:45 +02:00
|
|
|
_distributedCache.RefreshDictionaryCache(entity.Id);
|
2021-03-25 14:51:00 +01:00
|
|
|
}
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
2021-03-25 14:51:00 +01:00
|
|
|
public void Handle(DictionaryItemDeletedNotification notification)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2021-03-25 14:51:00 +01:00
|
|
|
foreach (IDictionaryItem entity in notification.DeletedEntities)
|
|
|
|
|
{
|
2017-07-11 19:13:45 +02:00
|
|
|
_distributedCache.RemoveDictionaryCache(entity.Id);
|
2021-03-25 14:51:00 +01:00
|
|
|
}
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region DataTypeService
|
2017-05-12 14:49:44 +02:00
|
|
|
|
2021-03-30 09:25:34 +01:00
|
|
|
public void Handle(DataTypeSavedNotification notification)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2021-03-30 11:14:50 +02:00
|
|
|
foreach (IDataType entity in notification.SavedEntities)
|
|
|
|
|
{
|
2017-07-11 19:13:45 +02:00
|
|
|
_distributedCache.RefreshDataTypeCache(entity);
|
2021-03-30 11:14:50 +02:00
|
|
|
}
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
2021-03-30 09:25:34 +01:00
|
|
|
public void Handle(DataTypeDeletedNotification notification)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2021-03-30 11:14:50 +02:00
|
|
|
foreach (IDataType entity in notification.DeletedEntities)
|
|
|
|
|
{
|
2017-07-11 19:13:45 +02:00
|
|
|
_distributedCache.RemoveDataTypeCache(entity);
|
2021-03-30 11:14:50 +02:00
|
|
|
}
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region DomainService
|
|
|
|
|
|
2021-03-31 13:26:31 +02:00
|
|
|
public void Handle(DomainSavedNotification notification)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2021-03-31 13:26:31 +02:00
|
|
|
foreach (IDomain entity in notification.SavedEntities)
|
|
|
|
|
{
|
2017-07-11 19:13:45 +02:00
|
|
|
_distributedCache.RefreshDomainCache(entity);
|
2021-03-31 13:26:31 +02:00
|
|
|
}
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
2021-03-31 13:26:31 +02:00
|
|
|
public void Handle(DomainDeletedNotification notification)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2021-03-31 13:26:31 +02:00
|
|
|
foreach (IDomain entity in notification.DeletedEntities)
|
|
|
|
|
{
|
2017-07-11 19:13:45 +02:00
|
|
|
_distributedCache.RemoveDomainCache(entity);
|
2021-03-31 13:26:31 +02:00
|
|
|
}
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region LocalizationService / Language
|
2017-05-12 14:49:44 +02:00
|
|
|
|
2016-09-08 18:43:58 +02:00
|
|
|
/// <summary>
|
2019-01-26 10:52:19 -05:00
|
|
|
/// Fires when a language is deleted
|
2016-09-08 18:43:58 +02:00
|
|
|
/// </summary>
|
2021-03-25 14:51:00 +01:00
|
|
|
/// <param name="notification"></param>
|
|
|
|
|
public void Handle(LanguageDeletedNotification notification)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2021-03-25 14:51:00 +01:00
|
|
|
foreach (ILanguage entity in notification.DeletedEntities)
|
|
|
|
|
{
|
2017-07-11 19:13:45 +02:00
|
|
|
_distributedCache.RemoveLanguageCache(entity);
|
2021-03-25 14:51:00 +01:00
|
|
|
}
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2019-01-26 10:52:19 -05:00
|
|
|
/// Fires when a language is saved
|
2016-09-08 18:43:58 +02:00
|
|
|
/// </summary>
|
2021-03-25 14:51:00 +01:00
|
|
|
/// <param name="notification"></param>
|
|
|
|
|
public void Handle(LanguageSavedNotification notification)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2021-03-25 14:51:00 +01:00
|
|
|
foreach (ILanguage entity in notification.SavedEntities)
|
|
|
|
|
{
|
2017-07-11 19:13:45 +02:00
|
|
|
_distributedCache.RefreshLanguageCache(entity);
|
2021-03-25 14:51:00 +01:00
|
|
|
}
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Content|Media|MemberTypeService
|
|
|
|
|
|
2017-07-11 19:13:45 +02:00
|
|
|
private void ContentTypeService_Changed(IContentTypeService sender, ContentTypeChange<IContentType>.EventArgs args)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2017-07-11 19:13:45 +02:00
|
|
|
_distributedCache.RefreshContentTypeCache(args.Changes.ToArray());
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
2017-07-11 19:13:45 +02:00
|
|
|
private void MediaTypeService_Changed(IMediaTypeService sender, ContentTypeChange<IMediaType>.EventArgs args)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2017-07-11 19:13:45 +02:00
|
|
|
_distributedCache.RefreshContentTypeCache(args.Changes.ToArray());
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
2017-07-11 19:13:45 +02:00
|
|
|
private void MemberTypeService_Changed(IMemberTypeService sender, ContentTypeChange<IMemberType>.EventArgs args)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2017-07-11 19:13:45 +02:00
|
|
|
_distributedCache.RefreshContentTypeCache(args.Changes.ToArray());
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
2019-01-27 01:17:32 -05:00
|
|
|
// TODO: our weird events handling wants this for now
|
2017-07-11 19:13:45 +02:00
|
|
|
private void ContentTypeService_Saved(IContentTypeService sender, SaveEventArgs<IContentType> args) { }
|
|
|
|
|
private void MediaTypeService_Saved(IMediaTypeService sender, SaveEventArgs<IMediaType> args) { }
|
|
|
|
|
private void MemberTypeService_Saved(IMemberTypeService sender, SaveEventArgs<IMemberType> args) { }
|
|
|
|
|
private void ContentTypeService_Deleted(IContentTypeService sender, DeleteEventArgs<IContentType> args) { }
|
|
|
|
|
private void MediaTypeService_Deleted(IMediaTypeService sender, DeleteEventArgs<IMediaType> args) { }
|
|
|
|
|
private void MemberTypeService_Deleted(IMemberTypeService sender, DeleteEventArgs<IMemberType> args) { }
|
2017-06-23 18:54:42 +02:00
|
|
|
|
2016-09-08 18:43:58 +02:00
|
|
|
#endregion
|
|
|
|
|
|
2017-09-14 11:41:46 +02:00
|
|
|
#region UserService
|
2016-09-08 18:43:58 +02:00
|
|
|
|
2021-03-29 10:42:42 +02:00
|
|
|
public void Handle(UserSavedNotification notification)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2021-03-29 10:42:42 +02:00
|
|
|
foreach (IUser entity in notification.SavedEntities)
|
|
|
|
|
{
|
2017-07-11 19:13:45 +02:00
|
|
|
_distributedCache.RefreshUserCache(entity.Id);
|
2021-03-29 10:42:42 +02:00
|
|
|
}
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
2021-03-29 10:42:42 +02:00
|
|
|
public void Handle(UserDeletedNotification notification)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2021-03-29 10:42:42 +02:00
|
|
|
foreach (IUser entity in notification.DeletedEntities)
|
|
|
|
|
{
|
2017-07-11 19:13:45 +02:00
|
|
|
_distributedCache.RemoveUserCache(entity.Id);
|
2021-03-29 10:42:42 +02:00
|
|
|
}
|
2017-09-14 11:41:46 +02:00
|
|
|
}
|
|
|
|
|
|
2021-03-29 10:42:42 +02:00
|
|
|
public void Handle(UserGroupWithUsersSavedNotification notification)
|
2017-09-14 11:41:46 +02:00
|
|
|
{
|
2021-03-29 10:42:42 +02:00
|
|
|
foreach (UserGroupWithUsers entity in notification.SavedEntities)
|
|
|
|
|
{
|
2018-03-27 10:04:07 +02:00
|
|
|
_distributedCache.RefreshUserGroupCache(entity.UserGroup.Id);
|
2021-03-29 10:42:42 +02:00
|
|
|
}
|
2017-09-14 11:41:46 +02:00
|
|
|
}
|
|
|
|
|
|
2021-03-29 10:42:42 +02:00
|
|
|
public void Handle(UserGroupDeletedNotification notification)
|
2017-09-14 11:41:46 +02:00
|
|
|
{
|
2021-03-29 10:42:42 +02:00
|
|
|
foreach (IUserGroup entity in notification.DeletedEntities)
|
|
|
|
|
{
|
2017-09-14 11:41:46 +02:00
|
|
|
_distributedCache.RemoveUserGroupCache(entity.Id);
|
2021-03-29 10:42:42 +02:00
|
|
|
}
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2017-06-23 18:54:42 +02:00
|
|
|
#region FileService
|
2016-09-08 18:43:58 +02:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Removes cache for template
|
|
|
|
|
/// </summary>
|
2021-03-30 12:14:32 +02:00
|
|
|
/// <param name="notification"></param>
|
|
|
|
|
public void Handle(TemplateDeletedNotification notification)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2021-03-30 12:14:32 +02:00
|
|
|
foreach (ITemplate entity in notification.DeletedEntities)
|
|
|
|
|
{
|
2017-07-11 19:13:45 +02:00
|
|
|
_distributedCache.RemoveTemplateCache(entity.Id);
|
2021-03-30 12:14:32 +02:00
|
|
|
}
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Refresh cache for template
|
|
|
|
|
/// </summary>
|
2021-03-30 14:01:37 +02:00
|
|
|
/// <param name="notification"></param>
|
|
|
|
|
public void Handle(TemplateSavedNotification notification)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2021-03-30 14:01:37 +02:00
|
|
|
foreach (ITemplate entity in notification.SavedEntities)
|
|
|
|
|
{
|
2017-07-11 19:13:45 +02:00
|
|
|
_distributedCache.RefreshTemplateCache(entity.Id);
|
2021-03-30 14:01:37 +02:00
|
|
|
}
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region MacroService
|
|
|
|
|
|
2021-03-29 15:09:26 +02:00
|
|
|
public void Handle(MacroDeletedNotification notification)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2021-03-29 15:09:26 +02:00
|
|
|
foreach (IMacro entity in notification.DeletedEntities)
|
|
|
|
|
{
|
2020-01-23 19:48:15 +11:00
|
|
|
_distributedCache.RemoveMacroCache(entity);
|
2021-03-29 15:09:26 +02:00
|
|
|
}
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
2021-03-29 15:09:26 +02:00
|
|
|
public void Handle(MacroSavedNotification notification)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2021-03-29 15:09:26 +02:00
|
|
|
foreach (IMacro entity in notification.SavedEntities)
|
|
|
|
|
{
|
2020-01-23 19:48:15 +11:00
|
|
|
_distributedCache.RefreshMacroCache(entity);
|
2021-03-29 15:09:26 +02:00
|
|
|
}
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region MediaService
|
|
|
|
|
|
2019-03-04 16:38:47 +01:00
|
|
|
private void MediaService_TreeChanged(IMediaService sender, TreeChange<IMedia>.EventArgs args)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2017-07-11 19:13:45 +02:00
|
|
|
_distributedCache.RefreshMediaCache(args.Changes.ToArray());
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region MemberService
|
|
|
|
|
|
2021-03-29 10:42:42 +02:00
|
|
|
public void Handle(MemberDeletedNotification notification)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2021-03-29 10:42:42 +02:00
|
|
|
_distributedCache.RemoveMemberCache(notification.DeletedEntities.ToArray());
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
2021-03-29 10:42:42 +02:00
|
|
|
public void Handle(MemberSavedNotification notification)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2021-03-29 10:42:42 +02:00
|
|
|
_distributedCache.RefreshMemberCache(notification.SavedEntities.ToArray());
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region MemberGroupService
|
|
|
|
|
|
2021-03-26 18:47:06 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Fires when a member group is deleted
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="notification"></param>
|
|
|
|
|
public void Handle(MemberGroupDeletedNotification notification)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2021-03-26 18:47:06 +01:00
|
|
|
foreach (IMemberGroup entity in notification.DeletedEntities)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2021-03-26 18:47:06 +01:00
|
|
|
_distributedCache.RemoveMemberGroupCache(entity.Id);
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-26 18:47:06 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Fires when a member group is saved
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="notification"></param>
|
|
|
|
|
public void Handle(MemberGroupSavedNotification notification)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2021-03-26 18:47:06 +01:00
|
|
|
foreach (IMemberGroup entity in notification.SavedEntities)
|
2016-09-08 18:43:58 +02:00
|
|
|
{
|
2021-03-26 18:47:06 +01:00
|
|
|
_distributedCache.RemoveMemberGroupCache(entity.Id);
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
|
|
|
|
}
|
2019-01-02 15:24:05 +01:00
|
|
|
|
2016-09-08 18:43:58 +02:00
|
|
|
#endregion
|
2017-05-12 14:49:44 +02:00
|
|
|
|
|
|
|
|
#region RelationType
|
|
|
|
|
|
2021-03-31 11:52:36 +02:00
|
|
|
public void Handle(RelationTypeSavedNotification notification)
|
2017-05-12 14:49:44 +02:00
|
|
|
{
|
2021-03-31 11:52:36 +02:00
|
|
|
DistributedCache dc = _distributedCache;
|
|
|
|
|
foreach (IRelationType entity in notification.SavedEntities)
|
|
|
|
|
{
|
|
|
|
|
dc.RefreshRelationTypeCache(entity.Id);
|
|
|
|
|
}
|
2017-05-12 14:49:44 +02:00
|
|
|
}
|
|
|
|
|
|
2021-03-31 11:52:36 +02:00
|
|
|
public void Handle(RelationTypeDeletedNotification notification)
|
2017-05-12 14:49:44 +02:00
|
|
|
{
|
2021-03-31 11:52:36 +02:00
|
|
|
DistributedCache dc = _distributedCache;
|
|
|
|
|
foreach (IRelationType entity in notification.DeletedEntities)
|
|
|
|
|
{
|
|
|
|
|
dc.RemoveRelationTypeCache(entity.Id);
|
|
|
|
|
}
|
2017-05-12 14:49:44 +02:00
|
|
|
}
|
2017-07-20 11:21:28 +02:00
|
|
|
|
2017-05-12 14:49:44 +02:00
|
|
|
#endregion
|
2016-09-08 18:43:58 +02:00
|
|
|
}
|
2017-07-20 11:21:28 +02:00
|
|
|
}
|