2013-02-06 09:53:13 +06:00
|
|
|
|
using System;
|
|
|
|
|
|
using Umbraco.Core;
|
2013-03-12 03:00:42 +04:00
|
|
|
|
using Umbraco.Core.Cache;
|
2014-01-13 18:36:08 +11:00
|
|
|
|
using Umbraco.Core.Models;
|
2015-01-13 13:25:36 +11:00
|
|
|
|
using Umbraco.Core.Models.Membership;
|
2015-01-13 13:33:39 +11:00
|
|
|
|
|
2013-03-12 17:08:31 +04:00
|
|
|
|
using umbraco.cms.businesslogic.member;
|
2015-01-13 13:25:36 +11:00
|
|
|
|
using Umbraco.Core.Persistence.Repositories;
|
2013-02-06 09:53:13 +06:00
|
|
|
|
using umbraco.interfaces;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Cache
|
|
|
|
|
|
{
|
2013-03-18 21:18:22 +06:00
|
|
|
|
/// <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>
|
2014-03-06 18:25:38 +11:00
|
|
|
|
public class MemberCacheRefresher : TypedCacheRefresherBase<MemberCacheRefresher, IMember>
|
2013-02-06 09:53:13 +06:00
|
|
|
|
{
|
|
|
|
|
|
|
2013-03-21 22:53:58 +06:00
|
|
|
|
protected override MemberCacheRefresher Instance
|
2013-02-06 09:53:13 +06:00
|
|
|
|
{
|
2013-03-21 22:53:58 +06:00
|
|
|
|
get { return this; }
|
2013-02-06 09:53:13 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-03-21 22:53:58 +06:00
|
|
|
|
public override Guid UniqueIdentifier
|
2013-02-06 09:53:13 +06:00
|
|
|
|
{
|
2013-03-21 22:53:58 +06:00
|
|
|
|
get { return new Guid(DistributedCache.MemberCacheRefresherId); }
|
2013-02-06 09:53:13 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-03-21 22:53:58 +06:00
|
|
|
|
public override string Name
|
2013-02-06 09:53:13 +06:00
|
|
|
|
{
|
2013-03-22 05:04:32 +06:00
|
|
|
|
get { return "Clears Member Cache"; }
|
2013-02-06 09:53:13 +06:00
|
|
|
|
}
|
2013-03-21 22:53:58 +06:00
|
|
|
|
|
|
|
|
|
|
public override void Refresh(int id)
|
2013-02-06 09:53:13 +06:00
|
|
|
|
{
|
2013-02-07 05:53:59 +06:00
|
|
|
|
ClearCache(id);
|
2013-03-21 22:53:58 +06:00
|
|
|
|
base.Refresh(id);
|
2013-02-06 09:53:13 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-03-21 22:53:58 +06:00
|
|
|
|
public override void Remove(int id)
|
2013-02-06 09:53:13 +06:00
|
|
|
|
{
|
2013-02-07 05:53:59 +06:00
|
|
|
|
ClearCache(id);
|
2013-03-21 22:53:58 +06:00
|
|
|
|
base.Remove(id);
|
2013-02-07 05:53:59 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
2014-03-06 18:25:38 +11:00
|
|
|
|
public override void Refresh(IMember instance)
|
|
|
|
|
|
{
|
|
|
|
|
|
ClearCache(instance.Id);
|
2014-03-20 12:36:13 +11:00
|
|
|
|
base.Refresh(instance);
|
2014-03-06 18:25:38 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Remove(IMember instance)
|
|
|
|
|
|
{
|
|
|
|
|
|
ClearCache(instance.Id);
|
|
|
|
|
|
base.Remove(instance);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-02-07 05:53:59 +06:00
|
|
|
|
private void ClearCache(int id)
|
|
|
|
|
|
{
|
2013-10-18 16:13:41 +11:00
|
|
|
|
ApplicationContext.Current.ApplicationCache.ClearPartialViewCache();
|
|
|
|
|
|
|
2015-01-13 13:25:36 +11:00
|
|
|
|
ApplicationContext.Current.ApplicationCache.RuntimeCache.
|
2013-03-22 04:34:57 +06:00
|
|
|
|
ClearCacheByKeySearch(string.Format("{0}_{1}", CacheKeys.MemberLibraryCacheKey, id));
|
2015-01-13 13:25:36 +11:00
|
|
|
|
ApplicationContext.Current.ApplicationCache.RuntimeCache.
|
2013-03-22 04:34:57 +06:00
|
|
|
|
ClearCacheByKeySearch(string.Format("{0}{1}", CacheKeys.MemberBusinessLogicCacheKey, id));
|
2014-01-13 18:36:08 +11:00
|
|
|
|
|
2015-01-13 13:25:36 +11:00
|
|
|
|
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(RepositoryBase.GetCacheIdKey<IMember>(id));
|
2013-02-06 09:53:13 +06:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|