Fixes: U4-4873 RuntimeCacheRefresher does not remove items when media or content requires cache refreshing & U4-4871 Synced media indexes between load balanced servers do not sync all properties

This commit is contained in:
Shannon
2014-05-13 10:40:56 +10:00
parent 313d77eb91
commit 937e840104
2 changed files with 46 additions and 8 deletions

View File

@@ -7,6 +7,7 @@ using Umbraco.Core.Cache;
using Umbraco.Core.Events;
using Umbraco.Core.IO;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence.Caching;
using umbraco.interfaces;
using System.Linq;
@@ -155,6 +156,7 @@ namespace Umbraco.Web.Cache
payloads.ForEach(payload =>
{
//if there's no path, then just use id (this will occur on permanent deletion like emptying recycle bin)
if (payload.Path.IsNullOrWhiteSpace())
{
@@ -165,6 +167,12 @@ namespace Umbraco.Web.Cache
{
foreach (var idPart in payload.Path.Split(','))
{
int idPartAsInt;
if (int.TryParse(idPart, out idPartAsInt))
{
RuntimeCacheProvider.Current.Delete(typeof(IMedia), idPartAsInt);
}
ApplicationContext.Current.ApplicationCache.ClearCacheByKeySearch(
string.Format("{0}_{1}_True", CacheKeys.MediaCacheKey, idPart));

View File

@@ -3,22 +3,16 @@ using System.Web.Script.Serialization;
using Umbraco.Core.Cache;
using Umbraco.Core.Models;
using System.Linq;
using Umbraco.Core.Persistence.Caching;
using Umbraco.Core.Sync;
namespace Umbraco.Web.Cache
{
/// <summary>
/// A cache refresher used for non-published content, this is primarily to notify Examine indexes to update
/// A cache refresher used for non-published content, this is primarily to notify Examine indexes to update and to refresh the RuntimeCacheRefresher
/// </summary>
public sealed class UnpublishedPageCacheRefresher : TypedCacheRefresherBase<UnpublishedPageCacheRefresher, IContent>, IJsonCacheRefresher
{
//NOTE: There is no functionality for this cache refresher, it is here simply to emit events on each server for which examine
// binds to. We could put the Examine index functionality in here but we've kept it all in the ExamineEvents class so that all of
// the logic is in one place. In the future we may put the examine logic in a cache refresher instead (that would make sense) but we'd
// want to get this done before making more cache refreshers:
// http://issues.umbraco.org/issue/U4-2633
protected override UnpublishedPageCacheRefresher Instance
{
get { return this; }
@@ -78,12 +72,48 @@ namespace Umbraco.Web.Cache
#endregion
public override void RefreshAll()
{
RuntimeCacheProvider.Current.Clear(typeof(IContent));
base.RefreshAll();
}
public override void Refresh(int id)
{
RuntimeCacheProvider.Current.Delete(typeof(IContent), id);
base.Refresh(id);
}
public override void Remove(int id)
{
RuntimeCacheProvider.Current.Delete(typeof(IContent), id);
base.Remove(id);
}
public override void Refresh(IContent instance)
{
RuntimeCacheProvider.Current.Delete(typeof(IContent), instance.Id);
base.Refresh(instance);
}
public override void Remove(IContent instance)
{
RuntimeCacheProvider.Current.Delete(typeof(IContent), instance.Id);
base.Remove(instance);
}
/// <summary>
/// Implement the IJsonCacheRefresher so that we can bulk delete the cache based on multiple IDs for when the recycle bin is emptied
/// </summary>
/// <param name="jsonPayload"></param>
public void Refresh(string jsonPayload)
{
foreach (var payload in DeserializeFromJsonPayload(jsonPayload))
{
RuntimeCacheProvider.Current.Delete(typeof(IContent), payload.Id);
}
OnCacheUpdated(Instance, new CacheRefresherEventArgs(jsonPayload, MessageType.RefreshByJson));
}