diff --git a/src/Umbraco.Web/Cache/LibraryCacheRefresher.cs b/src/Umbraco.Web/Cache/CacheRefresherEventHandler.cs
similarity index 75%
rename from src/Umbraco.Web/Cache/LibraryCacheRefresher.cs
rename to src/Umbraco.Web/Cache/CacheRefresherEventHandler.cs
index 9176a8d328..1fb49ee9df 100644
--- a/src/Umbraco.Web/Cache/LibraryCacheRefresher.cs
+++ b/src/Umbraco.Web/Cache/CacheRefresherEventHandler.cs
@@ -2,24 +2,32 @@
using Umbraco.Core.Services;
using umbraco;
using umbraco.cms.businesslogic;
+using umbraco.cms.businesslogic.macro;
using umbraco.cms.businesslogic.member;
using System.Linq;
namespace Umbraco.Web.Cache
{
///
- /// Special class made to listen to save events on objects where umbraco.library caches some of their objects
+ /// Class which listens to events on business level objects in order to invalidate the cache amongst servers when data changes
///
- public class LibraryCacheRefresher : ApplicationEventHandler
+ public class CacheRefresherEventHandler : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
if (UmbracoSettings.UmbracoLibraryCacheDuration <= 0) return;
+ //Bind to macro events
+
+ Macro.AfterSave += MacroAfterSave;
+
+ //Bind to member events
Member.AfterSave += MemberAfterSave;
Member.BeforeDelete += MemberBeforeDelete;
+ //Bind to media events
+
MediaService.Saved += MediaServiceSaved;
//We need to perform all of the 'before' events here because we need a reference to the
//media item's Path before it is moved/deleting/trashed
@@ -29,6 +37,16 @@ namespace Umbraco.Web.Cache
MediaService.Trashing += MediaServiceTrashing;
}
+ ///
+ /// Flush macro from cache
+ ///
+ ///
+ ///
+ static void MacroAfterSave(Macro sender, SaveEventArgs e)
+ {
+ DistributedCache.Instance.RefreshMacroCache(sender.Id);
+ }
+
static void MediaServiceTrashing(IMediaService sender, Core.Events.MoveEventArgs e)
{
ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMedia(e.Entity.Id);
diff --git a/src/Umbraco.Web/Cache/MacroCacheRefresher.cs b/src/Umbraco.Web/Cache/MacroCacheRefresher.cs
index 69c5025c3e..2f5c53a6e9 100644
--- a/src/Umbraco.Web/Cache/MacroCacheRefresher.cs
+++ b/src/Umbraco.Web/Cache/MacroCacheRefresher.cs
@@ -4,6 +4,9 @@ using umbraco.interfaces;
namespace Umbraco.Web.Cache
{
+ ///
+ /// Used to invalidate/refresh the cache for macros
+ ///
public class MacroCacheRefresher : ICacheRefresher
{
public string Name
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index baf582add3..23f525464b 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -247,7 +247,7 @@
-
+
diff --git a/src/Umbraco.Web/umbraco.presentation/LibraryCacheRefresher.cs b/src/Umbraco.Web/umbraco.presentation/LibraryCacheRefresher.cs
index b29e7f951c..3cb9133552 100644
--- a/src/Umbraco.Web/umbraco.presentation/LibraryCacheRefresher.cs
+++ b/src/Umbraco.Web/umbraco.presentation/LibraryCacheRefresher.cs
@@ -9,7 +9,7 @@ namespace umbraco
{
[Obsolete("This class is no longer used, use Umbraco.Web.Cache.LibraryCacheRefresher instead")]
- public class LibraryCacheRefresher : Umbraco.Web.Cache.LibraryCacheRefresher
+ public class LibraryCacheRefresher : Umbraco.Web.Cache.CacheRefresherEventHandler
{
}
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Macros/editMacro.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Macros/editMacro.aspx.cs
index 44685e9c0b..d420dae7da 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Macros/editMacro.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Macros/editMacro.aspx.cs
@@ -109,10 +109,6 @@ namespace umbraco.cms.presentation.developer
}
- // Flush macro from cache!
- DistributedCache.Instance.RefreshMacroCache(macroID);
-
-
ClientTools.ShowSpeechBubble(speechBubbleIcon.save, "Macro saved", "");