Splits into files, adds ICacheRefresherNotificationFactory, removes Init method
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
using System;
|
||||
using System;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
public sealed class ApplicationCacheRefresher : CacheRefresherBase<ApplicationCacheRefresherNotification>
|
||||
{
|
||||
public ApplicationCacheRefresher(AppCaches appCaches, IEventAggregator eventAggregator)
|
||||
: base(appCaches, eventAggregator)
|
||||
{ }
|
||||
public ApplicationCacheRefresher(AppCaches appCaches, IEventAggregator eventAggregator, ICacheRefresherNotificationFactory factory)
|
||||
: base(appCaches, eventAggregator, factory)
|
||||
{
|
||||
}
|
||||
|
||||
#region Define
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
public class ApplicationCacheRefresherNotification : CacheRefresherNotification
|
||||
{
|
||||
public ApplicationCacheRefresherNotification(object messageObject, MessageType messageType) : base(messageObject, messageType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Models.Entities;
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
@@ -10,17 +10,18 @@ namespace Umbraco.Cms.Core.Cache
|
||||
/// </summary>
|
||||
/// <typeparam name="TInstanceType">The actual cache refresher type.</typeparam>
|
||||
/// <remarks>The actual cache refresher type is used for strongly typed events.</remarks>
|
||||
public abstract class CacheRefresherBase< TNotification> : ICacheRefresher
|
||||
where TNotification : CacheRefresherNotificationBase, new()
|
||||
public abstract class CacheRefresherBase<TNotification> : ICacheRefresher
|
||||
where TNotification : CacheRefresherNotification
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CacheRefresherBase{TInstanceType}"/>.
|
||||
/// </summary>
|
||||
/// <param name="appCaches">A cache helper.</param>
|
||||
protected CacheRefresherBase(AppCaches appCaches, IEventAggregator eventAggregator)
|
||||
protected CacheRefresherBase(AppCaches appCaches, IEventAggregator eventAggregator, ICacheRefresherNotificationFactory factory)
|
||||
{
|
||||
AppCaches = appCaches;
|
||||
EventAggregator = eventAggregator;
|
||||
NotificationFactory = factory;
|
||||
}
|
||||
|
||||
#region Define
|
||||
@@ -35,6 +36,11 @@ namespace Umbraco.Cms.Core.Cache
|
||||
/// </summary>
|
||||
public abstract string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="TNotificationFactory"/> for <see cref="TNotification"/>
|
||||
/// </summary>
|
||||
protected ICacheRefresherNotificationFactory NotificationFactory { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Refresher
|
||||
@@ -44,7 +50,7 @@ namespace Umbraco.Cms.Core.Cache
|
||||
/// </summary>
|
||||
public virtual void RefreshAll()
|
||||
{
|
||||
OnCacheUpdated(new TNotification().Init(null, MessageType.RefreshAll));
|
||||
OnCacheUpdated(NotificationFactory.Create<TNotification>(null, MessageType.RefreshAll));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -53,7 +59,7 @@ namespace Umbraco.Cms.Core.Cache
|
||||
/// <param name="id">The entity's identifier.</param>
|
||||
public virtual void Refresh(int id)
|
||||
{
|
||||
OnCacheUpdated(new TNotification().Init(id, MessageType.RefreshById));
|
||||
OnCacheUpdated(NotificationFactory.Create<TNotification>(id, MessageType.RefreshById));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -62,7 +68,7 @@ namespace Umbraco.Cms.Core.Cache
|
||||
/// <param name="id">The entity's identifier.</param>
|
||||
public virtual void Refresh(Guid id)
|
||||
{
|
||||
OnCacheUpdated(new TNotification().Init(id, MessageType.RefreshById));
|
||||
OnCacheUpdated(NotificationFactory.Create<TNotification>(id, MessageType.RefreshById));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -71,7 +77,7 @@ namespace Umbraco.Cms.Core.Cache
|
||||
/// <param name="id">The entity's identifier.</param>
|
||||
public virtual void Remove(int id)
|
||||
{
|
||||
OnCacheUpdated(new TNotification().Init(id, MessageType.RemoveById));
|
||||
OnCacheUpdated(NotificationFactory.Create<TNotification>(id, MessageType.RemoveById));
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -100,7 +106,7 @@ namespace Umbraco.Cms.Core.Cache
|
||||
/// </summary>
|
||||
/// <param name="sender">The event sender.</param>
|
||||
/// <param name="args">The event arguments.</param>
|
||||
protected void OnCacheUpdated(CacheRefresherNotificationBase notification)
|
||||
protected void OnCacheUpdated(CacheRefresherNotification notification)
|
||||
{
|
||||
EventAggregator.Publish(notification);
|
||||
}
|
||||
|
||||
22
src/Umbraco.Core/Cache/CacheRefresherNotification.cs
Normal file
22
src/Umbraco.Core/Cache/CacheRefresherNotification.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for cache refresher notifications
|
||||
/// </summary>
|
||||
public abstract class CacheRefresherNotification : INotification
|
||||
{
|
||||
public CacheRefresherNotification(object messageObject, MessageType messageType)
|
||||
{
|
||||
MessageObject = messageObject ?? throw new ArgumentNullException(nameof(messageObject));
|
||||
MessageType = messageType;
|
||||
}
|
||||
|
||||
public object MessageObject { get; }
|
||||
public MessageType MessageType { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
/// <summary>
|
||||
/// Event args for cache refresher updates
|
||||
/// </summary>
|
||||
public abstract class CacheRefresherNotificationBase : INotification
|
||||
{
|
||||
public CacheRefresherNotificationBase Init(object msgObject, MessageType type)
|
||||
{
|
||||
MessageType = type;
|
||||
MessageObject = msgObject;
|
||||
|
||||
return this;
|
||||
}
|
||||
public object MessageObject { get; private set; }
|
||||
public MessageType MessageType { get; private set;}
|
||||
}
|
||||
public class DataTypeCacheRefresherNotification : CacheRefresherNotificationBase
|
||||
{
|
||||
}
|
||||
|
||||
public class UserCacheRefresherNotification : CacheRefresherNotificationBase
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public class ContentCacheRefresherNotification : CacheRefresherNotificationBase
|
||||
{
|
||||
}
|
||||
|
||||
public class TemplateCacheRefresherNotification : CacheRefresherNotificationBase
|
||||
{
|
||||
}
|
||||
|
||||
public class RelationTypeCacheRefresherNotification : CacheRefresherNotificationBase
|
||||
{
|
||||
}
|
||||
|
||||
public class PublicAccessCacheRefresherNotification : CacheRefresherNotificationBase
|
||||
{
|
||||
}
|
||||
|
||||
public class MemberGroupCacheRefresherNotification : CacheRefresherNotificationBase
|
||||
{
|
||||
}
|
||||
|
||||
public class MemberCacheRefresherNotification : CacheRefresherNotificationBase
|
||||
{
|
||||
}
|
||||
|
||||
public class MediaCacheRefresherNotification : CacheRefresherNotificationBase
|
||||
{
|
||||
}
|
||||
|
||||
public class UserGroupCacheRefresherNotification : CacheRefresherNotificationBase
|
||||
{
|
||||
}
|
||||
|
||||
public class LanguageCacheRefresherNotification : CacheRefresherNotificationBase
|
||||
{
|
||||
}
|
||||
public class MacroCacheRefresherNotification : CacheRefresherNotificationBase
|
||||
{
|
||||
}
|
||||
|
||||
public class DomainCacheRefresherNotification : CacheRefresherNotificationBase
|
||||
{
|
||||
}
|
||||
|
||||
public class ContentTypeCacheRefresherNotification : CacheRefresherNotificationBase
|
||||
{
|
||||
}
|
||||
|
||||
public class ApplicationCacheRefresherNotification : CacheRefresherNotificationBase
|
||||
{
|
||||
}
|
||||
public class DictionaryCacheRefresherNotification : CacheRefresherNotificationBase
|
||||
{
|
||||
}
|
||||
}
|
||||
22
src/Umbraco.Core/Cache/CacheRefresherNotificationFactory.cs
Normal file
22
src/Umbraco.Core/Cache/CacheRefresherNotificationFactory.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="ICacheRefresherNotificationFactory"/> that uses ActivatorUtilities to create the <see cref="CacheRefresherNotification"/> instances
|
||||
/// </summary>
|
||||
public sealed class CacheRefresherNotificationFactory : ICacheRefresherNotificationFactory
|
||||
{
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
public CacheRefresherNotificationFactory(IServiceProvider serviceProvider) => _serviceProvider = serviceProvider;
|
||||
|
||||
/// <summary>
|
||||
/// Create a <see cref="CacheRefresherNotification"/> using ActivatorUtilities
|
||||
/// </summary>
|
||||
/// <typeparam name="TNotification">The <see cref="CacheRefresherNotification"/> to create</typeparam>
|
||||
public TNotification Create<TNotification>(object msgObject, MessageType type) where TNotification : CacheRefresherNotification
|
||||
=> _serviceProvider.CreateInstance<TNotification>(new object[] { msgObject, type });
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
@@ -24,8 +24,9 @@ namespace Umbraco.Cms.Core.Cache
|
||||
IPublishedSnapshotService publishedSnapshotService,
|
||||
IIdKeyMap idKeyMap,
|
||||
IDomainService domainService,
|
||||
IEventAggregator eventAggregator)
|
||||
: base(appCaches, serializer, eventAggregator)
|
||||
IEventAggregator eventAggregator,
|
||||
ICacheRefresherNotificationFactory factory)
|
||||
: base(appCaches, serializer, eventAggregator, factory)
|
||||
{
|
||||
_publishedSnapshotService = publishedSnapshotService;
|
||||
_idKeyMap = idKeyMap;
|
||||
|
||||
11
src/Umbraco.Core/Cache/ContentCacheRefresherNotification.cs
Normal file
11
src/Umbraco.Core/Cache/ContentCacheRefresherNotification.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
public class ContentCacheRefresherNotification : CacheRefresherNotification
|
||||
{
|
||||
public ContentCacheRefresherNotification(object messageObject, MessageType messageType) : base(messageObject, messageType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
@@ -26,8 +26,9 @@ namespace Umbraco.Cms.Core.Cache
|
||||
IPublishedModelFactory publishedModelFactory,
|
||||
IIdKeyMap idKeyMap,
|
||||
IContentTypeCommonRepository contentTypeCommonRepository,
|
||||
IEventAggregator eventAggregator)
|
||||
: base(appCaches, serializer, eventAggregator)
|
||||
IEventAggregator eventAggregator,
|
||||
ICacheRefresherNotificationFactory factory)
|
||||
: base(appCaches, serializer, eventAggregator, factory)
|
||||
{
|
||||
_publishedSnapshotService = publishedSnapshotService;
|
||||
_publishedModelFactory = publishedModelFactory;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
public class ContentTypeCacheRefresherNotification : CacheRefresherNotification
|
||||
{
|
||||
public ContentTypeCacheRefresherNotification(object messageObject, MessageType messageType) : base(messageObject, messageType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Models.PublishedContent;
|
||||
@@ -22,8 +22,9 @@ namespace Umbraco.Cms.Core.Cache
|
||||
IPublishedSnapshotService publishedSnapshotService,
|
||||
IPublishedModelFactory publishedModelFactory,
|
||||
IIdKeyMap idKeyMap,
|
||||
IEventAggregator eventAggregator)
|
||||
: base(appCaches, serializer, eventAggregator)
|
||||
IEventAggregator eventAggregator,
|
||||
ICacheRefresherNotificationFactory factory)
|
||||
: base(appCaches, serializer, eventAggregator, factory)
|
||||
{
|
||||
_publishedSnapshotService = publishedSnapshotService;
|
||||
_publishedModelFactory = publishedModelFactory;
|
||||
|
||||
11
src/Umbraco.Core/Cache/DataTypeCacheRefresherNotification.cs
Normal file
11
src/Umbraco.Core/Cache/DataTypeCacheRefresherNotification.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
public class DataTypeCacheRefresherNotification : CacheRefresherNotification
|
||||
{
|
||||
public DataTypeCacheRefresherNotification(object messageObject, MessageType messageType) : base(messageObject, messageType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
|
||||
@@ -6,8 +6,8 @@ namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
public sealed class DictionaryCacheRefresher : CacheRefresherBase<DictionaryCacheRefresherNotification>
|
||||
{
|
||||
public DictionaryCacheRefresher(AppCaches appCaches, IEventAggregator eventAggregator)
|
||||
: base(appCaches, eventAggregator)
|
||||
public DictionaryCacheRefresher(AppCaches appCaches, IEventAggregator eventAggregator, ICacheRefresherNotificationFactory factory)
|
||||
: base(appCaches, eventAggregator , factory)
|
||||
{ }
|
||||
|
||||
#region Define
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
public class DictionaryCacheRefresherNotification : CacheRefresherNotification
|
||||
{
|
||||
public DictionaryCacheRefresherNotification(object messageObject, MessageType messageType) : base(messageObject, messageType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.PublishedCache;
|
||||
@@ -15,8 +15,9 @@ namespace Umbraco.Cms.Core.Cache
|
||||
AppCaches appCaches,
|
||||
IJsonSerializer serializer,
|
||||
IPublishedSnapshotService publishedSnapshotService,
|
||||
IEventAggregator eventAggregator)
|
||||
: base(appCaches, serializer, eventAggregator)
|
||||
IEventAggregator eventAggregator,
|
||||
ICacheRefresherNotificationFactory factory)
|
||||
: base(appCaches, serializer, eventAggregator, factory)
|
||||
{
|
||||
_publishedSnapshotService = publishedSnapshotService;
|
||||
}
|
||||
|
||||
11
src/Umbraco.Core/Cache/DomainCacheRefresherNotification.cs
Normal file
11
src/Umbraco.Core/Cache/DomainCacheRefresherNotification.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
public class DomainCacheRefresherNotification : CacheRefresherNotification
|
||||
{
|
||||
public DomainCacheRefresherNotification(object messageObject, MessageType messageType) : base(messageObject, messageType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
16
src/Umbraco.Core/Cache/ICacheRefresherNotificationFactory.cs
Normal file
16
src/Umbraco.Core/Cache/ICacheRefresherNotificationFactory.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
/// <summary>
|
||||
/// Factory for creating cache refresher notification instances
|
||||
/// </summary>
|
||||
public interface ICacheRefresherNotificationFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a <see cref="ICacheRefresherNotification"/>
|
||||
/// </summary>
|
||||
/// <typeparam name="TNotification">The <see cref="ICacheRefresherNotification"/> to create</typeparam>
|
||||
TNotification Create<TNotification>(object msgObject, MessageType type) where TNotification : CacheRefresherNotification;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Serialization;
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Umbraco.Cms.Core.Cache
|
||||
/// <typeparam name="TInstanceType">The actual cache refresher type.</typeparam>
|
||||
/// <remarks>The actual cache refresher type is used for strongly typed events.</remarks>
|
||||
public abstract class JsonCacheRefresherBase<TNotification, TJsonPayload> : CacheRefresherBase<TNotification>, IJsonCacheRefresher
|
||||
where TNotification : CacheRefresherNotificationBase, new()
|
||||
where TNotification : CacheRefresherNotification
|
||||
{
|
||||
protected IJsonSerializer JsonSerializer { get; }
|
||||
|
||||
@@ -21,8 +21,9 @@ namespace Umbraco.Cms.Core.Cache
|
||||
protected JsonCacheRefresherBase(
|
||||
AppCaches appCaches,
|
||||
IJsonSerializer jsonSerializer,
|
||||
IEventAggregator eventAggregator)
|
||||
: base(appCaches, eventAggregator)
|
||||
IEventAggregator eventAggregator,
|
||||
ICacheRefresherNotificationFactory factory)
|
||||
: base(appCaches, eventAggregator, factory)
|
||||
{
|
||||
JsonSerializer = jsonSerializer;
|
||||
}
|
||||
@@ -33,7 +34,7 @@ namespace Umbraco.Cms.Core.Cache
|
||||
/// <param name="json">The json payload.</param>
|
||||
public virtual void Refresh(string json)
|
||||
{
|
||||
OnCacheUpdated(new TNotification().Init(json, MessageType.RefreshByJson));
|
||||
OnCacheUpdated(NotificationFactory.Create<TNotification>(json, MessageType.RefreshByJson));
|
||||
}
|
||||
|
||||
#region Json
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.PublishedCache;
|
||||
@@ -14,8 +14,9 @@ namespace Umbraco.Cms.Core.Cache
|
||||
AppCaches appCaches,
|
||||
IJsonSerializer serializer,
|
||||
IPublishedSnapshotService publishedSnapshotService,
|
||||
IEventAggregator eventAggregator)
|
||||
: base(appCaches, serializer, eventAggregator)
|
||||
IEventAggregator eventAggregator,
|
||||
ICacheRefresherNotificationFactory factory)
|
||||
: base(appCaches, serializer, eventAggregator, factory)
|
||||
{
|
||||
_publishedSnapshotService = publishedSnapshotService;
|
||||
}
|
||||
|
||||
11
src/Umbraco.Core/Cache/LanguageCacheRefresherNotification.cs
Normal file
11
src/Umbraco.Core/Cache/LanguageCacheRefresherNotification.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
public class LanguageCacheRefresherNotification : CacheRefresherNotification
|
||||
{
|
||||
public LanguageCacheRefresherNotification(object messageObject, MessageType messageType) : base(messageObject, messageType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
@@ -12,8 +12,9 @@ namespace Umbraco.Cms.Core.Cache
|
||||
public MacroCacheRefresher(
|
||||
AppCaches appCaches,
|
||||
IJsonSerializer jsonSerializer,
|
||||
IEventAggregator eventAggregator)
|
||||
: base(appCaches, jsonSerializer, eventAggregator)
|
||||
IEventAggregator eventAggregator,
|
||||
ICacheRefresherNotificationFactory factory)
|
||||
: base(appCaches, jsonSerializer, eventAggregator, factory)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
11
src/Umbraco.Core/Cache/MacroCacheRefresherNotification.cs
Normal file
11
src/Umbraco.Core/Cache/MacroCacheRefresherNotification.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
public class MacroCacheRefresherNotification : CacheRefresherNotification
|
||||
{
|
||||
public MacroCacheRefresherNotification(object messageObject, MessageType messageType) : base(messageObject, messageType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Persistence.Repositories;
|
||||
@@ -15,8 +15,8 @@ namespace Umbraco.Cms.Core.Cache
|
||||
private readonly IPublishedSnapshotService _publishedSnapshotService;
|
||||
private readonly IIdKeyMap _idKeyMap;
|
||||
|
||||
public MediaCacheRefresher(AppCaches appCaches, IJsonSerializer serializer, IPublishedSnapshotService publishedSnapshotService, IIdKeyMap idKeyMap, IEventAggregator eventAggregator)
|
||||
: base(appCaches, serializer, eventAggregator)
|
||||
public MediaCacheRefresher(AppCaches appCaches, IJsonSerializer serializer, IPublishedSnapshotService publishedSnapshotService, IIdKeyMap idKeyMap, IEventAggregator eventAggregator, ICacheRefresherNotificationFactory factory)
|
||||
: base(appCaches, serializer, eventAggregator, factory)
|
||||
{
|
||||
_publishedSnapshotService = publishedSnapshotService;
|
||||
_idKeyMap = idKeyMap;
|
||||
|
||||
11
src/Umbraco.Core/Cache/MediaCacheRefresherNotification.cs
Normal file
11
src/Umbraco.Core/Cache/MediaCacheRefresherNotification.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
public class MediaCacheRefresherNotification : CacheRefresherNotification
|
||||
{
|
||||
public MediaCacheRefresherNotification(object messageObject, MessageType messageType) : base(messageObject, messageType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,8 @@ namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
private readonly IIdKeyMap _idKeyMap;
|
||||
|
||||
public MemberCacheRefresher(AppCaches appCaches, IJsonSerializer serializer, IIdKeyMap idKeyMap, IEventAggregator eventAggregator)
|
||||
: base(appCaches, serializer, eventAggregator)
|
||||
public MemberCacheRefresher(AppCaches appCaches, IJsonSerializer serializer, IIdKeyMap idKeyMap, IEventAggregator eventAggregator, ICacheRefresherNotificationFactory factory)
|
||||
: base(appCaches, serializer, eventAggregator, factory)
|
||||
{
|
||||
_idKeyMap = idKeyMap;
|
||||
}
|
||||
|
||||
11
src/Umbraco.Core/Cache/MemberCacheRefresherNotification.cs
Normal file
11
src/Umbraco.Core/Cache/MemberCacheRefresherNotification.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
public class MemberCacheRefresherNotification : CacheRefresherNotification
|
||||
{
|
||||
public MemberCacheRefresherNotification(object messageObject, MessageType messageType) : base(messageObject, messageType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Serialization;
|
||||
@@ -7,8 +7,8 @@ namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
public sealed class MemberGroupCacheRefresher : PayloadCacheRefresherBase<MemberGroupCacheRefresherNotification, MemberGroupCacheRefresher.JsonPayload>
|
||||
{
|
||||
public MemberGroupCacheRefresher(AppCaches appCaches, IJsonSerializer jsonSerializer, IEventAggregator eventAggregator)
|
||||
: base(appCaches, jsonSerializer, eventAggregator)
|
||||
public MemberGroupCacheRefresher(AppCaches appCaches, IJsonSerializer jsonSerializer, IEventAggregator eventAggregator, ICacheRefresherNotificationFactory factory)
|
||||
: base(appCaches, jsonSerializer, eventAggregator, factory)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
public class MemberGroupCacheRefresherNotification : CacheRefresherNotification
|
||||
{
|
||||
public MemberGroupCacheRefresherNotification(object messageObject, MessageType messageType) : base(messageObject, messageType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Serialization;
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
@@ -11,8 +11,7 @@ namespace Umbraco.Cms.Core.Cache
|
||||
/// <typeparam name="TPayload">The payload type.</typeparam>
|
||||
/// <remarks>The actual cache refresher type is used for strongly typed events.</remarks>
|
||||
public abstract class PayloadCacheRefresherBase<TNotification, TPayload> : JsonCacheRefresherBase<TNotification, TPayload>, IPayloadCacheRefresher<TPayload>
|
||||
where TNotification : CacheRefresherNotificationBase, new()
|
||||
|
||||
where TNotification : CacheRefresherNotification
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
@@ -20,8 +19,8 @@ namespace Umbraco.Cms.Core.Cache
|
||||
/// </summary>
|
||||
/// <param name="appCaches">A cache helper.</param>
|
||||
/// <param name="serializer"></param>
|
||||
protected PayloadCacheRefresherBase(AppCaches appCaches, IJsonSerializer serializer, IEventAggregator eventAggregator)
|
||||
: base(appCaches, serializer, eventAggregator)
|
||||
protected PayloadCacheRefresherBase(AppCaches appCaches, IJsonSerializer serializer, IEventAggregator eventAggregator, ICacheRefresherNotificationFactory factory)
|
||||
: base(appCaches, serializer, eventAggregator, factory)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -40,7 +39,7 @@ namespace Umbraco.Cms.Core.Cache
|
||||
/// <param name="payloads">The payload.</param>
|
||||
public virtual void Refresh(TPayload[] payloads)
|
||||
{
|
||||
OnCacheUpdated(new TNotification().Init(payloads, MessageType.RefreshByPayload));
|
||||
OnCacheUpdated(NotificationFactory.Create<TNotification>(payloads, MessageType.RefreshByPayload));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
|
||||
@@ -6,8 +6,8 @@ namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
public sealed class PublicAccessCacheRefresher : CacheRefresherBase<PublicAccessCacheRefresherNotification>
|
||||
{
|
||||
public PublicAccessCacheRefresher(AppCaches appCaches, IEventAggregator eventAggregator)
|
||||
: base(appCaches, eventAggregator)
|
||||
public PublicAccessCacheRefresher(AppCaches appCaches, IEventAggregator eventAggregator, ICacheRefresherNotificationFactory factory)
|
||||
: base(appCaches, eventAggregator, factory)
|
||||
{ }
|
||||
|
||||
#region Define
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
public class PublicAccessCacheRefresherNotification : CacheRefresherNotification
|
||||
{
|
||||
public PublicAccessCacheRefresherNotification(object messageObject, MessageType messageType) : base(messageObject, messageType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Persistence.Repositories;
|
||||
@@ -7,8 +7,8 @@ namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
public sealed class RelationTypeCacheRefresher : CacheRefresherBase<RelationTypeCacheRefresherNotification>
|
||||
{
|
||||
public RelationTypeCacheRefresher(AppCaches appCaches, IEventAggregator eventAggregator)
|
||||
: base(appCaches, eventAggregator)
|
||||
public RelationTypeCacheRefresher(AppCaches appCaches, IEventAggregator eventAggregator, ICacheRefresherNotificationFactory factory)
|
||||
: base(appCaches, eventAggregator, factory)
|
||||
{ }
|
||||
|
||||
#region Define
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
public class RelationTypeCacheRefresherNotification : CacheRefresherNotification
|
||||
{
|
||||
public RelationTypeCacheRefresherNotification(object messageObject, MessageType messageType) : base(messageObject, messageType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Persistence.Repositories;
|
||||
@@ -11,8 +11,8 @@ namespace Umbraco.Cms.Core.Cache
|
||||
private readonly IIdKeyMap _idKeyMap;
|
||||
private readonly IContentTypeCommonRepository _contentTypeCommonRepository;
|
||||
|
||||
public TemplateCacheRefresher(AppCaches appCaches, IIdKeyMap idKeyMap, IContentTypeCommonRepository contentTypeCommonRepository, IEventAggregator eventAggregator)
|
||||
: base(appCaches, eventAggregator)
|
||||
public TemplateCacheRefresher(AppCaches appCaches, IIdKeyMap idKeyMap, IContentTypeCommonRepository contentTypeCommonRepository, IEventAggregator eventAggregator, ICacheRefresherNotificationFactory factory)
|
||||
: base(appCaches, eventAggregator, factory)
|
||||
{
|
||||
_idKeyMap = idKeyMap;
|
||||
_contentTypeCommonRepository = contentTypeCommonRepository;
|
||||
|
||||
11
src/Umbraco.Core/Cache/TemplateCacheRefresherNotification.cs
Normal file
11
src/Umbraco.Core/Cache/TemplateCacheRefresherNotification.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
public class TemplateCacheRefresherNotification : CacheRefresherNotification
|
||||
{
|
||||
public TemplateCacheRefresherNotification(object messageObject, MessageType messageType) : base(messageObject, messageType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Models.Membership;
|
||||
using Umbraco.Cms.Core.Persistence.Repositories;
|
||||
@@ -7,8 +7,8 @@ namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
public sealed class UserCacheRefresher : CacheRefresherBase<UserCacheRefresherNotification>
|
||||
{
|
||||
public UserCacheRefresher(AppCaches appCaches, IEventAggregator eventAggregator)
|
||||
: base(appCaches, eventAggregator)
|
||||
public UserCacheRefresher(AppCaches appCaches, IEventAggregator eventAggregator, ICacheRefresherNotificationFactory factory)
|
||||
: base(appCaches, eventAggregator, factory)
|
||||
{ }
|
||||
|
||||
#region Define
|
||||
|
||||
11
src/Umbraco.Core/Cache/UserCacheRefresherNotification.cs
Normal file
11
src/Umbraco.Core/Cache/UserCacheRefresherNotification.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
public class UserCacheRefresherNotification : CacheRefresherNotification
|
||||
{
|
||||
public UserCacheRefresherNotification(object messageObject, MessageType messageType) : base(messageObject, messageType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Models.Membership;
|
||||
using Umbraco.Cms.Core.Persistence.Repositories;
|
||||
@@ -13,8 +13,8 @@ namespace Umbraco.Cms.Core.Cache
|
||||
/// </remarks>
|
||||
public sealed class UserGroupCacheRefresher : CacheRefresherBase<UserGroupCacheRefresherNotification>
|
||||
{
|
||||
public UserGroupCacheRefresher(AppCaches appCaches, IEventAggregator eventAggregator)
|
||||
: base(appCaches, eventAggregator)
|
||||
public UserGroupCacheRefresher(AppCaches appCaches, IEventAggregator eventAggregator, ICacheRefresherNotificationFactory factory)
|
||||
: base(appCaches, eventAggregator, factory)
|
||||
{ }
|
||||
|
||||
#region Define
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Core.Cache
|
||||
{
|
||||
public class UserGroupCacheRefresherNotification : CacheRefresherNotification
|
||||
{
|
||||
public UserGroupCacheRefresherNotification(object messageObject, MessageType messageType) : base(messageObject, messageType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,6 +189,7 @@ namespace Umbraco.Cms.Core.DependencyInjection
|
||||
|
||||
// register distributed cache
|
||||
Services.AddUnique(f => new DistributedCache(f.GetRequiredService<IServerMessenger>(), f.GetRequiredService<CacheRefresherCollection>()));
|
||||
Services.AddUnique<ICacheRefresherNotificationFactory, CacheRefresherNotificationFactory>();
|
||||
|
||||
// register the http context and umbraco context accessors
|
||||
// we *should* use the HttpContextUmbracoContextAccessor, however there are cases when
|
||||
|
||||
Reference in New Issue
Block a user