Fixes: #U4-1981 - ensures template cache is properly refreshed amonsgst all servers

This commit is contained in:
Shannon Deminick
2013-03-22 02:08:55 +06:00
parent 9d6b38a1c1
commit ee2f2dfda0
6 changed files with 60 additions and 37 deletions

View File

@@ -60,9 +60,12 @@ namespace Umbraco.Web.Cache
User.Deleting += UserDeleting;
//Bind to template events
//NOTE: we need to bind to legacy and new API events currently: http://issues.umbraco.org/issue/U4-1979
Template.AfterSave += TemplateAfterSave;
Template.AfterDelete += TemplateAfterDelete;
FileService.SavedTemplate += FileServiceSavedTemplate;
FileService.DeletedTemplate += FileServiceDeletedTemplate;
//Bind to macro events
@@ -241,6 +244,27 @@ namespace Umbraco.Web.Cache
#endregion
#region Template event handlers
/// <summary>
/// Removes cache for template
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
static void FileServiceDeletedTemplate(IFileService sender, Core.Events.DeleteEventArgs<ITemplate> e)
{
e.DeletedEntities.ForEach(x => DistributedCache.Instance.RemoveTemplateCache(x.Id));
}
/// <summary>
/// Refresh cache for template
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
static void FileServiceSavedTemplate(IFileService sender, Core.Events.SaveEventArgs<ITemplate> e)
{
e.SavedEntities.ForEach(x => DistributedCache.Instance.RefreshTemplateCache(x.Id));
}
/// <summary>
/// Removes cache for template
/// </summary>

View File

@@ -45,6 +45,7 @@ namespace Umbraco.Web.Cache
{
dc.Remove(new Guid(DistributedCache.TemplateRefresherId), templateId);
}
#endregion
#region Page cache

View File

@@ -50,8 +50,11 @@ namespace Umbraco.Web.Cache
private void RemoveFromCache(int id)
{
ApplicationContext.Current.ApplicationCache.ClearCacheByKeySearch(
string.Format("{0}{1}", CacheKeys.TemplateCacheKey, id));
ApplicationContext.Current.ApplicationCache.ClearCacheItem(
string.Format("{0}{1}", CacheKeys.TemplateFrontEndCacheKey, id));
ApplicationContext.Current.ApplicationCache.ClearCacheItem(
string.Format("{0}{1}", CacheKeys.TemplateBusinessLogicCacheKey, id));
}
}