using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Cms.Core.Sync;
namespace Umbraco.Cms.Core.Cache;
///
/// A base class for "payload" class refreshers.
///
/// The payload type.
/// The notification type
/// The actual cache refresher type is used for strongly typed events.
public abstract class
PayloadCacheRefresherBase : JsonCacheRefresherBase,
IPayloadCacheRefresher
where TNotification : CacheRefresherNotification
{
///
/// Initializes a new instance of the .
///
/// A cache helper.
///
///
///
protected PayloadCacheRefresherBase(AppCaches appCaches, IJsonSerializer serializer, IEventAggregator eventAggregator, ICacheRefresherNotificationFactory factory)
: base(appCaches, serializer, eventAggregator, factory)
{
}
#region Refresher
public override void Refresh(string json)
{
TPayload[]? payload = Deserialize(json);
if (payload is not null)
{
Refresh(payload);
}
}
///
/// Refreshes as specified by a payload.
///
/// The payload.
public virtual void Refresh(TPayload[] payloads) =>
OnCacheUpdated(NotificationFactory.Create(payloads, MessageType.RefreshByPayload));
#endregion
}