2021-02-18 11:06:02 +01:00
|
|
|
|
using Umbraco.Cms.Core.Serialization;
|
|
|
|
|
|
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>
|
2020-01-22 14:09:20 +01:00
|
|
|
|
public abstract class PayloadCacheRefresherBase<TInstanceType, TPayload> : JsonCacheRefresherBase<TInstanceType, TPayload>, IPayloadCacheRefresher<TPayload>
|
2016-05-26 17:12:04 +02:00
|
|
|
|
where TInstanceType : class, ICacheRefresher
|
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>
|
2020-01-22 14:09:20 +01:00
|
|
|
|
protected PayloadCacheRefresherBase(AppCaches appCaches, IJsonSerializer serializer) : base(appCaches, serializer)
|
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
|
|
|
|
{
|
2017-07-11 19:21:13 +02:00
|
|
|
|
OnCacheUpdated(This, new CacheRefresherEventArgs(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
|
|
|
|
}
|
|
|
|
|
|
}
|