Streamlines how Member cache data gets invalidated

This commit is contained in:
Shannon Deminick
2013-02-07 04:57:44 +06:00
parent ea24e43c90
commit cf8a0728d8
6 changed files with 11 additions and 34 deletions

View File

@@ -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);
}
}
}

View File

@@ -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)

View File

@@ -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>

View File

@@ -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" />

View File

@@ -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>

View File

@@ -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
{
}