I can't find a good example of this, and I'm guessing a little but I think knowing the MessageType is RefreshByPayload, means you can cast the MessageObject into they type of Payload, and loop through each Payload, and it's ChangeType to determine a little about what is going on.
Have a look at the Examine ContentCacheRefresherUpdated event handling implementation in the core:
foreach (var payload in (ContentCacheRefresher.JsonPayload[])args.MessageObject)
{
if (payload.ChangeTypes.HasType(TreeChangeTypes.Remove))
{
// delete content entirely (with descendants)
// false: remove entirely from all indexes
DeleteIndexForEntity(payload.Id, false);
}
The ChangeTypes enum is here;
public enum TreeChangeTypes : byte
{
None = 0,
// all items have been refreshed
RefreshAll = 1,
// an item node has been refreshed
// with only local impact
RefreshNode = 2,
// an item node has been refreshed
// with branch impact
RefreshBranch = 4,
// an item node has been removed
// never to return
Remove = 8,
}
So you should be able to tell the difference between an Unpublish and a Publish.
PageCacheRefresher in Umbraco V8
Anyone knows what's the new PageCacheRefresher events on distributed servers on the new Umbraco V8?
Thanks
Hi JLon
I think you might be after this?
regards
Marc
Thanks Marc :)
Hey Marc,
Do you also know if there's a way we can detect the type of the event.
Eg if it's a Save and Publish or even if it's Unpublishing on a content?
When I debug through the e.MessageObject within the ContentCacheRefresher_CacheUpdated()
It keeps coming back as MessageType.RefreshByPayload for Save and Publish or Unpublishing
Thanks
Hi Jeric
I can't find a good example of this, and I'm guessing a little but I think knowing the MessageType is RefreshByPayload, means you can cast the MessageObject into they type of Payload, and loop through each Payload, and it's ChangeType to determine a little about what is going on.
Have a look at the Examine ContentCacheRefresherUpdated event handling implementation in the core:
https://github.com/umbraco/Umbraco-CMS/blob/13488be0a3280c966ca5115c1cf75cc1979e5819/src/Umbraco.Web/Search/ExamineComponent.cs#L133
The ChangeTypes enum is here;
So you should be able to tell the difference between an Unpublish and a Publish.
regards
Marc
Thanks Marc
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.