2013-03-22 00:49:07 +06:00
|
|
|
|
using System;
|
|
|
|
|
|
using Umbraco.Core.Cache;
|
2015-07-27 12:53:09 +02:00
|
|
|
|
using Umbraco.Core.Models;
|
2016-06-08 14:19:15 +02:00
|
|
|
|
using Umbraco.Core.Services.Changes;
|
2013-03-22 05:15:58 +06:00
|
|
|
|
using Umbraco.Web.PublishedCache;
|
2013-03-22 00:49:07 +06:00
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Cache
|
|
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
public sealed class DomainCacheRefresher : PayloadCacheRefresherBase<DomainCacheRefresher, DomainCacheRefresher.JsonPayload>
|
2013-03-22 00:49:07 +06:00
|
|
|
|
{
|
2017-10-31 12:48:24 +01:00
|
|
|
|
private readonly IPublishedSnapshotService _publishedSnapshotService;
|
2016-05-18 18:44:08 +02:00
|
|
|
|
|
2017-10-31 12:48:24 +01:00
|
|
|
|
public DomainCacheRefresher(CacheHelper cacheHelper, IPublishedSnapshotService publishedSnapshotService)
|
2016-05-26 17:12:04 +02:00
|
|
|
|
: base(cacheHelper)
|
2013-03-22 00:49:07 +06:00
|
|
|
|
{
|
2017-10-31 12:48:24 +01:00
|
|
|
|
_publishedSnapshotService = publishedSnapshotService;
|
2013-03-22 00:49:07 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
#region Define
|
|
|
|
|
|
|
2017-07-11 19:21:13 +02:00
|
|
|
|
protected override DomainCacheRefresher This => this;
|
2016-05-26 17:12:04 +02:00
|
|
|
|
|
|
|
|
|
|
public static readonly Guid UniqueId = Guid.Parse("11290A79-4B57-4C99-AD72-7748A3CF38AF");
|
|
|
|
|
|
|
|
|
|
|
|
public override Guid RefresherUniqueId => UniqueId;
|
2013-03-22 00:49:07 +06:00
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
public override string Name => "Domain Cache Refresher";
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Refresher
|
|
|
|
|
|
|
|
|
|
|
|
public override void Refresh(JsonPayload[] payloads)
|
2013-03-22 00:49:07 +06:00
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
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
|
2017-10-31 12:48:24 +01:00
|
|
|
|
_publishedSnapshotService.Notify(payloads);
|
2016-05-26 17:12:04 +02:00
|
|
|
|
// then trigger event
|
|
|
|
|
|
base.Refresh(payloads);
|
2013-03-22 00:49:07 +06:00
|
|
|
|
}
|
2016-03-30 17:56:34 +02:00
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
// these events should never trigger
|
|
|
|
|
|
// everything should be PAYLOAD/JSON
|
|
|
|
|
|
|
2016-03-30 17:56:34 +02:00
|
|
|
|
public override void RefreshAll()
|
|
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
throw new NotSupportedException();
|
2016-03-30 17:56:34 +02:00
|
|
|
|
}
|
2013-03-22 00:49:07 +06:00
|
|
|
|
|
|
|
|
|
|
public override void Refresh(int id)
|
|
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
throw new NotSupportedException();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Refresh(Guid id)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new NotSupportedException();
|
2013-03-22 00:49:07 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Remove(int id)
|
|
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
throw new NotSupportedException();
|
2013-03-22 00:49:07 +06:00
|
|
|
|
}
|
2013-03-22 05:15:58 +06:00
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Json
|
2015-01-29 15:39:41 +11:00
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
public class JsonPayload
|
|
|
|
|
|
{
|
2016-06-08 14:19:15 +02:00
|
|
|
|
public JsonPayload(int id, DomainChangeTypes changeType)
|
2013-05-02 14:24:27 -10:00
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
Id = id;
|
|
|
|
|
|
ChangeType = changeType;
|
2013-05-02 14:24:27 -10:00
|
|
|
|
}
|
2016-05-26 17:12:04 +02:00
|
|
|
|
|
|
|
|
|
|
public int Id { get; }
|
|
|
|
|
|
|
2016-06-08 14:19:15 +02:00
|
|
|
|
public DomainChangeTypes ChangeType { get; }
|
2013-03-22 05:15:58 +06:00
|
|
|
|
}
|
2016-05-26 17:12:04 +02:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
2013-03-22 00:49:07 +06:00
|
|
|
|
}
|
2017-07-20 11:21:28 +02:00
|
|
|
|
}
|