Skip to content

Instantly share code, notes, and snippets.

@hartviglarsen
Created June 19, 2018 10:12
Show Gist options
  • Save hartviglarsen/cdbb82147ffd1e630fa675be425749ce to your computer and use it in GitHub Desktop.
Save hartviglarsen/cdbb82147ffd1e630fa675be425749ce to your computer and use it in GitHub Desktop.
Umbraco prevalues cache
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