Files
Umbraco-CMS/src/Umbraco.Web/Cache/MemberCacheRefresher.cs
T
Shannon Deminick 5f242aa3f6 Converts the media cache refresher to be a json cache refresher since it was impossible before to have media cache
cleared when media was deleted. Created base classes for cache refreshers, we now have a new event - CacheUpdated
which can now be used by code to execute on each individual server when any cache refresher is updated. Listening to events
normally only fire on the individual server so if people are wanting to refresh their own cache there was previously no way
to do that.
2013-03-21 22:53:58 +06:00

51 lines
1.4 KiB
C#

using System;
using Umbraco.Core;
using Umbraco.Core.Cache;
using umbraco.cms.businesslogic.member;
using umbraco.interfaces;
namespace Umbraco.Web.Cache
{
/// <summary>
/// A cache refresher to ensure member cache is updated when members change
/// </summary>
/// <remarks>
/// This is not intended to be used directly in your code and it should be sealed but due to legacy code we cannot seal it.
/// </remarks>
public class MemberCacheRefresher : CacheRefresherBase<MemberCacheRefresher>
{
protected override MemberCacheRefresher Instance
{
get { return this; }
}
public override Guid UniqueIdentifier
{
get { return new Guid(DistributedCache.MemberCacheRefresherId); }
}
public override string Name
{
get { return "Clears Member Cache from umbraco.library"; }
}
public override void Refresh(int id)
{
ClearCache(id);
base.Refresh(id);
}
public override void Remove(int id)
{
ClearCache(id);
base.Remove(id);
}
private void ClearCache(int id)
{
ApplicationContext.Current.ApplicationCache.
ClearCacheByKeySearch(string.Format("{0}_{1}", CacheKeys.MemberCacheKey, id));
}
}
}