I'm trying to maintain a hash table of episerver page ids to domain specific ids. The hash table uses the singleton pattern and is initially populated by running through the full list of pages. This mapping will need to be recreated however everytime the cache changes, say for example if a new piece of content is published.
My touble is I can't seem to find a way of detecting when the Episerver cache changes. No such change event appears to exists on the EPiServer.CacheManager class.
Does anybody have an idea of how I might detect such a cache change in episerver?
I'm assuming you're using EPiServer 7<.
If you only need to update the list when content is published, you can listen to content repository events:
public class EventsInitialization : IInitializableModule
private bool eventsAttached;
public void Initialize(InitializationEngine context)
var repository = ServiceLocator.Current.GetInstance<IContentEvents>();
repository.PublishedContent += this.PublishedContent;
eventsAttached = true;
public void Preload(string parameters)
throw new NotImplementedException();
public void Uninitialize(InitializationEngine context)
repository.PublishedContent -= this.PublishedContent;
eventsAttached = false;
private void PublishedContent(object sender, ContentEventArgs e)
// Do your magic here.