Fixes: #U4-1992 - Creates DictionaryCacheRefresher to ensure that all cache associated with the dictionary is updated amongst all

servers when it is changed/removed. Removes RemoveByJson as we only actually require RefreshByJson since we can put any sort of parameters
in a custom json string including whether it is a remove operation (if required)
This commit is contained in:
Shannon Deminick
2013-03-23 01:59:25 +06:00
parent af2693af76
commit e97a01c75c
22 changed files with 219 additions and 247 deletions

View File

@@ -11,7 +11,7 @@ namespace Umbraco.Web.Cache
/// <summary>
/// Extension methods for DistrubutedCache
/// </summary>
public static class DistributedCacheExtensions
internal static class DistributedCacheExtensions
{
#region User cache
public static void RemoveUserCache(this DistributedCache dc, int userId)
@@ -48,6 +48,30 @@ namespace Umbraco.Web.Cache
#endregion
#region Dictionary cache
/// <summary>
/// Refreshes the cache amongst servers for a dictionary item
/// </summary>
/// <param name="dc"></param>
/// <param name="dictionaryItemId"></param>
public static void RefreshDictionaryCache(this DistributedCache dc, int dictionaryItemId)
{
dc.Refresh(new Guid(DistributedCache.DictionaryCacheRefresherId), dictionaryItemId);
}
/// <summary>
/// Refreshes the cache amongst servers for a dictionary item
/// </summary>
/// <param name="dc"></param>
/// <param name="dictionaryItemId"></param>
public static void RemoveDictionaryCache(this DistributedCache dc, int dictionaryItemId)
{
dc.Remove(new Guid(DistributedCache.DictionaryCacheRefresherId), dictionaryItemId);
}
#endregion
#region Data type cache
/// <summary>
/// Refreshes the cache amongst servers for a template
@@ -179,7 +203,7 @@ namespace Umbraco.Web.Cache
/// <param name="media"></param>
public static void RemoveMediaCache(this DistributedCache dc, params IMedia[] media)
{
dc.RemoveByJson(new Guid(DistributedCache.MediaCacheRefresherId),
dc.RefreshByJson(new Guid(DistributedCache.MediaCacheRefresherId),
MediaCacheRefresher.SerializeToJsonPayload(media));
}
@@ -220,7 +244,7 @@ namespace Umbraco.Web.Cache
{
if (macro != null)
{
dc.RemoveByJson(new Guid(DistributedCache.MacroCacheRefresherId),
dc.RefreshByJson(new Guid(DistributedCache.MacroCacheRefresherId),
MacroCacheRefresher.SerializeToJsonPayload(macro));
}
}
@@ -234,7 +258,7 @@ namespace Umbraco.Web.Cache
{
if (macro != null && macro.Model != null)
{
dc.RemoveByJson(new Guid(DistributedCache.MacroCacheRefresherId),
dc.RefreshByJson(new Guid(DistributedCache.MacroCacheRefresherId),
MacroCacheRefresher.SerializeToJsonPayload(macro));
}
}
@@ -282,7 +306,7 @@ namespace Umbraco.Web.Cache
if (contentType != null)
{
//dc.Remove(new Guid(DistributedCache.ContentTypeCacheRefresherId), x => x.Id, contentType);
dc.RemoveByJson(new Guid(DistributedCache.ContentTypeCacheRefresherId),
dc.RefreshByJson(new Guid(DistributedCache.ContentTypeCacheRefresherId),
ContentTypeCacheRefresher.SerializeToJsonPayload(true, contentType));
}
}
@@ -297,7 +321,7 @@ namespace Umbraco.Web.Cache
if (mediaType != null)
{
//dc.Remove(new Guid(DistributedCache.ContentTypeCacheRefresherId), x => x.Id, mediaType);
dc.RemoveByJson(new Guid(DistributedCache.ContentTypeCacheRefresherId),
dc.RefreshByJson(new Guid(DistributedCache.ContentTypeCacheRefresherId),
ContentTypeCacheRefresher.SerializeToJsonPayload(true, mediaType));
}
}