Created
June 19, 2018 10:12
-
-
Save hartviglarsen/cdbb82147ffd1e630fa675be425749ce to your computer and use it in GitHub Desktop.
Umbraco prevalues cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using Umbraco.Core; | |
using Umbraco.Core.Logging; | |
public class RefreshPreVal : ApplicationEventHandler | |
{ | |
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) | |
{ | |
Umbraco.Core.Services.ContentService.Published += ContentService_Published; | |
} | |
void ContentService_Published(Umbraco.Core.Publishing.IPublishingStrategy sender, Umbraco.Core.Events.PublishEventArgs<Umbraco.Core.Models.IContent> e) | |
{ | |
var contentNode = e.PublishedEntities.ToList(); | |
if (contentNode.Any(x => x.ContentType.Alias == "person")) | |
{ | |
//Refresh Forms prevalues | |
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch("Forms.PreValues."); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment