diff --git a/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs b/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs
index a258cc0a59..470abb83db 100644
--- a/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs
+++ b/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs
@@ -195,5 +195,18 @@ namespace Umbraco.Web.Cache
dc.Remove(new Guid(DistributedCache.MacroCacheRefresherId), macro1 => macro1.Id, macro);
}
}
+
+ ///
+ /// Removes the cache amongst servers for a macro item
+ ///
+ ///
+ ///
+ public static void RemoveMacroCache(this DistributedCache dc, macro macro)
+ {
+ if (macro != null && macro.Model != null)
+ {
+ dc.Remove(new Guid(DistributedCache.MacroCacheRefresherId), macro1 => macro1.Model.Id, macro);
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Cache/MacroCacheRefresher.cs b/src/Umbraco.Web/Cache/MacroCacheRefresher.cs
index 0496a04d31..63cad42ae0 100644
--- a/src/Umbraco.Web/Cache/MacroCacheRefresher.cs
+++ b/src/Umbraco.Web/Cache/MacroCacheRefresher.cs
@@ -10,7 +10,7 @@ namespace Umbraco.Web.Cache
///
/// Used to invalidate/refresh the cache for macros
///
- public class MacroCacheRefresher : ICacheRefresher
+ public class MacroCacheRefresher : ICacheRefresher, ICacheRefresher
{
internal static string[] GetCacheKeys(string alias)
{
@@ -41,14 +41,14 @@ namespace Umbraco.Web.Cache
{
}
- void ICacheRefresher.Refresh(int id)
+ public void Refresh(int id)
{
if (id <= 0) return;
var m = new Macro(id);
Remove(m);
}
- void ICacheRefresher.Remove(int id)
+ public void Remove(int id)
{
if (id <= 0) return;
var m = new Macro(id);
@@ -70,5 +70,19 @@ namespace Umbraco.Web.Cache
}
}
+
+ public void Refresh(macro instance)
+ {
+ Remove(instance);
+ }
+
+ public void Remove(macro instance)
+ {
+ if (instance == null || instance.Model == null) return;
+ var m = instance.Model;
+ GetCacheKeys(m.Alias).ForEach(
+ alias =>
+ ApplicationContext.Current.ApplicationCache.ClearCacheItem(alias));
+ }
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Cache/MemberCacheRefresher.cs b/src/Umbraco.Web/Cache/MemberCacheRefresher.cs
index deb7c828fd..8fd8073945 100644
--- a/src/Umbraco.Web/Cache/MemberCacheRefresher.cs
+++ b/src/Umbraco.Web/Cache/MemberCacheRefresher.cs
@@ -1,11 +1,12 @@
using System;
using Umbraco.Core;
using Umbraco.Core.Cache;
+using umbraco.cms.businesslogic.member;
using umbraco.interfaces;
namespace Umbraco.Web.Cache
{
- public class MemberCacheRefresher : ICacheRefresher
+ public class MemberCacheRefresher : ICacheRefresher
{
public Guid UniqueIdentifier
@@ -43,5 +44,14 @@ namespace Umbraco.Web.Cache
ClearCacheByKeySearch(string.Format("UL_{0}_{1}", CacheKeys.GetMemberCacheKey, id));
}
+ public void Refresh(Member instance)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void Remove(Member instance)
+ {
+ throw new NotImplementedException();
+ }
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/umbraco.presentation/macro.cs b/src/Umbraco.Web/umbraco.presentation/macro.cs
index 1410ccbc8e..9d271d5064 100644
--- a/src/Umbraco.Web/umbraco.presentation/macro.cs
+++ b/src/Umbraco.Web/umbraco.presentation/macro.cs
@@ -201,7 +201,7 @@ namespace umbraco
{
if (this.Model != null)
{
- DistributedCache.Instance.RemoveMacroCache(this.Model.Id);
+ DistributedCache.Instance.RemoveMacroCache(this);
}
//this always returned false... hrm. oh well i guess we leave it like that
@@ -210,7 +210,7 @@ namespace umbraco
string GetCacheIdentifier(MacroModel model, Hashtable pageElements, int pageId)
{
- StringBuilder id = new StringBuilder();
+ var id = new StringBuilder();
var alias = string.IsNullOrEmpty(model.ScriptCode) ? model.Alias : Macro.GenerateCacheKeyFromCode(model.ScriptCode);
id.AppendFormat("{0}-", alias);