2021-03-15 13:39:34 +11:00
|
|
|
using Umbraco.Cms.Core.Events;
|
2021-03-12 21:48:24 +01:00
|
|
|
using Umbraco.Cms.Core.Serialization;
|
2021-02-18 11:06:02 +01:00
|
|
|
using Umbraco.Cms.Core.Sync;
|
2015-04-08 14:21:58 +02:00
|
|
|
|
2021-02-18 11:06:02 +01:00
|
|
|
namespace Umbraco.Cms.Core.Cache
|
2015-04-08 14:21:58 +02:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
2016-05-26 17:12:04 +02:00
|
|
|
/// A base class for "payload" class refreshers.
|
2015-04-08 14:21:58 +02:00
|
|
|
/// </summary>
|
2016-05-26 17:12:04 +02:00
|
|
|
/// <typeparam name="TInstanceType">The actual cache refresher type.</typeparam>
|
|
|
|
|
/// <typeparam name="TPayload">The payload type.</typeparam>
|
|
|
|
|
/// <remarks>The actual cache refresher type is used for strongly typed events.</remarks>
|
2021-03-12 21:48:24 +01:00
|
|
|
public abstract class PayloadCacheRefresherBase<TNotification, TPayload> : JsonCacheRefresherBase<TNotification, TPayload>, IPayloadCacheRefresher<TPayload>
|
2021-03-15 13:39:34 +11:00
|
|
|
where TNotification : CacheRefresherNotification
|
2015-04-08 14:21:58 +02:00
|
|
|
{
|
2019-11-07 21:28:56 +11:00
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes a new instance of the <see cref="PayloadCacheRefresherBase{TInstanceType, TPayload}"/>.
|
|
|
|
|
/// </summary>
|
2019-01-17 08:34:29 +01:00
|
|
|
/// <param name="appCaches">A cache helper.</param>
|
2019-11-07 21:28:56 +11:00
|
|
|
/// <param name="serializer"></param>
|
2021-03-15 13:39:34 +11:00
|
|
|
protected PayloadCacheRefresherBase(AppCaches appCaches, IJsonSerializer serializer, IEventAggregator eventAggregator, ICacheRefresherNotificationFactory factory)
|
|
|
|
|
: base(appCaches, serializer, eventAggregator, factory)
|
2019-11-07 21:28:56 +11:00
|
|
|
{
|
|
|
|
|
}
|
2016-05-26 17:12:04 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Refresher
|
2015-04-08 14:21:58 +02:00
|
|
|
|
|
|
|
|
public override void Refresh(string json)
|
|
|
|
|
{
|
|
|
|
|
var payload = Deserialize(json);
|
|
|
|
|
Refresh(payload);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Refreshes as specified by a payload.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="payloads">The payload.</param>
|
|
|
|
|
public virtual void Refresh(TPayload[] payloads)
|
2015-04-08 14:21:58 +02:00
|
|
|
{
|
2021-03-15 13:39:34 +11:00
|
|
|
OnCacheUpdated(NotificationFactory.Create<TNotification>(payloads, MessageType.RefreshByPayload));
|
2015-04-08 14:21:58 +02:00
|
|
|
}
|
2016-05-26 17:12:04 +02:00
|
|
|
|
|
|
|
|
#endregion
|
2015-04-08 14:21:58 +02:00
|
|
|
}
|
|
|
|
|
}
|