Streamlines how Member cache data gets invalidated
This commit is contained in:
@@ -75,12 +75,12 @@ namespace Umbraco.Web.Cache
|
||||
|
||||
static void MemberBeforeDelete(Member sender, DeleteEventArgs e)
|
||||
{
|
||||
ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMember(sender.Id);
|
||||
DistributedCache.Instance.RefreshMemberCache(sender.Id);
|
||||
}
|
||||
|
||||
static void MemberAfterSave(Member sender, SaveEventArgs e)
|
||||
{
|
||||
ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMember(sender.Id);
|
||||
DistributedCache.Instance.RefreshMemberCache(sender.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ using umbraco.interfaces;
|
||||
|
||||
namespace Umbraco.Web.Cache
|
||||
{
|
||||
public class MemberLibraryRefreshers : ICacheRefresher
|
||||
public class MemberCacheRefresher : ICacheRefresher
|
||||
{
|
||||
|
||||
public Guid UniqueIdentifier
|
||||
@@ -23,7 +23,10 @@ namespace Umbraco.Web.Cache
|
||||
|
||||
public void Refresh(int id)
|
||||
{
|
||||
ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMember(id, false);
|
||||
const string getmemberCacheKey = "GetMember";
|
||||
|
||||
ApplicationContext.Current.ApplicationCache.
|
||||
ClearCacheByKeySearch(string.Format("UL_{0}_{1}", getmemberCacheKey, id));
|
||||
}
|
||||
|
||||
public void Remove(int id)
|
||||
@@ -94,32 +94,6 @@ namespace Umbraco.Web
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the library cache for members
|
||||
/// </summary>
|
||||
/// <param name="cacheHelper"></param>
|
||||
/// <param name="memberId"></param>
|
||||
/// <param name="allServers">
|
||||
/// If set to false, this will only clear the library cache for the current server, not all servers registered in the
|
||||
/// server farm. In most cases if you are clearing cache you would probably clear it on all servers.
|
||||
/// </param>
|
||||
public static void ClearLibraryCacheForMember(this CacheHelper cacheHelper, int memberId, bool allServers = true)
|
||||
{
|
||||
const string getmemberCacheKey = "GetMember";
|
||||
|
||||
if (allServers && UmbracoSettings.UseDistributedCalls)
|
||||
{
|
||||
DistributedCache.Instance.RefreshMemberCache(memberId);
|
||||
}
|
||||
else
|
||||
{
|
||||
cacheHelper.ClearCacheByKeySearch(
|
||||
string.Format("UL_{0}_{1}", getmemberCacheKey, memberId));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -250,7 +250,7 @@
|
||||
<Compile Include="Cache\CacheRefresherEventHandler.cs" />
|
||||
<Compile Include="Cache\MacroCacheRefresher.cs" />
|
||||
<Compile Include="Cache\MediaLibraryRefreshers.cs" />
|
||||
<Compile Include="Cache\MemberLibraryRefreshers.cs" />
|
||||
<Compile Include="Cache\MemberCacheRefresher.cs" />
|
||||
<Compile Include="Cache\PageCacheRefresher.cs" />
|
||||
<Compile Include="Cache\TemplateCacheRefresher.cs" />
|
||||
<Compile Include="Dynamics\DynamicExpression.cs" />
|
||||
|
||||
@@ -1864,13 +1864,13 @@ namespace umbraco
|
||||
[Obsolete("Use ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMember instead")]
|
||||
public static void ClearLibraryCacheForMember(int mediaId)
|
||||
{
|
||||
ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMember(mediaId);
|
||||
DistributedCache.Instance.RefreshMemberCache(mediaId);
|
||||
}
|
||||
|
||||
[Obsolete("Use ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMember with the allServers flag set to false instead")]
|
||||
public static void ClearLibraryCacheForMemberDo(int memberId)
|
||||
{
|
||||
ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMember(memberId, false);
|
||||
DistributedCache.Instance.RefreshMemberCache(memberId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace umbraco.presentation.cache
|
||||
}
|
||||
|
||||
[Obsolete("This class is no longer used, use Umbraco.Web.Cache.MemberLibraryRefreshers instead")]
|
||||
public class MemberLibraryRefreshers : Umbraco.Web.Cache.MemberLibraryRefreshers
|
||||
public class MemberLibraryRefreshers : Umbraco.Web.Cache.MemberCacheRefresher
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user