Fixes: U4-3937 Ensure media is indexed across all servers in LB environment with Distributed Cache calls

This fix is for media indexes to be distributed properly and for unpublished content to be distributed properly, now to get members to do the same.
This commit is contained in:
Shannon
2014-03-06 17:50:08 +11:00
parent 4adc2562b1
commit d0cc93d6a2
9 changed files with 404 additions and 136 deletions

View File

@@ -123,8 +123,7 @@ namespace Umbraco.Web.Cache
}
#endregion
#region Data type cache
/// <summary>
/// Refreshes the cache amongst servers for a data type
@@ -232,7 +231,28 @@ namespace Umbraco.Web.Cache
public static void RemovePageCache(this DistributedCache dc, int documentId)
{
dc.Remove(new Guid(DistributedCache.PageCacheRefresherId), documentId);
}
}
/// <summary>
/// invokes the unpublished page cache refresher
/// </summary>
/// <param name="dc"></param>
/// <param name="content"></param>
public static void RefreshUnpublishedPageCache(this DistributedCache dc, params IContent[] content)
{
dc.Refresh(new Guid(DistributedCache.UnpublishedPageCacheRefresherId), x => x.Id, content);
}
/// <summary>
/// invokes the unpublished page cache refresher
/// </summary>
/// <param name="dc"></param>
/// <param name="content"></param>
public static void RemoveUnpublishedPageCache(this DistributedCache dc, params IContent[] content)
{
dc.Remove(new Guid(DistributedCache.UnpublishedPageCacheRefresherId), x => x.Id, content);
}
#endregion
#region Member cache
@@ -291,7 +311,7 @@ namespace Umbraco.Web.Cache
public static void RefreshMediaCache(this DistributedCache dc, params IMedia[] media)
{
dc.RefreshByJson(new Guid(DistributedCache.MediaCacheRefresherId),
MediaCacheRefresher.SerializeToJsonPayload(media));
MediaCacheRefresher.SerializeToJsonPayload(MediaCacheRefresher.OperationType.Saved, media));
}
/// <summary>
@@ -304,6 +324,7 @@ namespace Umbraco.Web.Cache
/// to clear all of the cache but the media item will be removed before the other servers can
/// look it up. Only here for legacy purposes.
/// </remarks>
[Obsolete("Ensure to clear with other RemoveMediaCache overload")]
public static void RemoveMediaCache(this DistributedCache dc, int mediaId)
{
dc.Remove(new Guid(DistributedCache.MediaCacheRefresherId), mediaId);
@@ -313,11 +334,14 @@ namespace Umbraco.Web.Cache
/// Removes the cache amongst servers for media items
/// </summary>
/// <param name="dc"></param>
/// <param name="isPermanentlyDeleted"></param>
/// <param name="media"></param>
public static void RemoveMediaCache(this DistributedCache dc, params IMedia[] media)
public static void RemoveMediaCache(this DistributedCache dc, bool isPermanentlyDeleted, params IMedia[] media)
{
dc.RefreshByJson(new Guid(DistributedCache.MediaCacheRefresherId),
MediaCacheRefresher.SerializeToJsonPayload(media));
dc.RefreshByJson(new Guid(DistributedCache.MediaCacheRefresherId),
MediaCacheRefresher.SerializeToJsonPayload(
isPermanentlyDeleted ? MediaCacheRefresher.OperationType.Deleted : MediaCacheRefresher.OperationType.Trashed,
media));
}
#endregion