Files
Umbraco-CMS/src/Umbraco.Core/Cache/DomainCacheRefresher.cs

83 lines
2.4 KiB
C#
Raw Normal View History

using System;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.PublishedCache;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Cms.Core.Services.Changes;
2018-06-29 19:52:40 +02:00
namespace Umbraco.Cms.Core.Cache
2018-06-29 19:52:40 +02:00
{
public sealed class DomainCacheRefresher : PayloadCacheRefresherBase<DomainCacheRefresherNotification, DomainCacheRefresher.JsonPayload>
2018-06-29 19:52:40 +02:00
{
private readonly IPublishedSnapshotService _publishedSnapshotService;
public DomainCacheRefresher(
AppCaches appCaches,
IJsonSerializer serializer,
IPublishedSnapshotService publishedSnapshotService,
IEventAggregator eventAggregator,
ICacheRefresherNotificationFactory factory)
: base(appCaches, serializer, eventAggregator, factory)
2018-06-29 19:52:40 +02:00
{
_publishedSnapshotService = publishedSnapshotService;
}
#region Define
public static readonly Guid UniqueId = Guid.Parse("11290A79-4B57-4C99-AD72-7748A3CF38AF");
public override Guid RefresherUniqueId => UniqueId;
public override string Name => "Domain Cache Refresher";
#endregion
2018-06-29 19:52:40 +02:00
#region Refresher
public override void Refresh(JsonPayload[] payloads)
{
ClearAllIsolatedCacheByEntityType<IDomain>();
// note: must do what's above FIRST else the repositories still have the old cached
// content and when the PublishedCachesService is notified of changes it does not see
// the new content...
// notify
_publishedSnapshotService.Notify(payloads);
// then trigger event
base.Refresh(payloads);
}
// these events should never trigger
// everything should be PAYLOAD/JSON
public override void RefreshAll() => throw new NotSupportedException();
2018-06-29 19:52:40 +02:00
public override void Refresh(int id) => throw new NotSupportedException();
2018-06-29 19:52:40 +02:00
public override void Refresh(Guid id) => throw new NotSupportedException();
2018-06-29 19:52:40 +02:00
public override void Remove(int id) => throw new NotSupportedException();
2018-06-29 19:52:40 +02:00
#endregion
#region Json
public class JsonPayload
{
public JsonPayload(int id, DomainChangeTypes changeType)
{
Id = id;
ChangeType = changeType;
}
public int Id { get; }
public DomainChangeTypes ChangeType { get; }
}
#endregion
}
}