2013-02-12 04:13:29 +06:00
|
|
|
|
using System;
|
2013-03-12 03:00:42 +04:00
|
|
|
|
using Umbraco.Core.Cache;
|
2014-01-28 10:46:59 +11:00
|
|
|
|
using Umbraco.Core.Models.Membership;
|
2015-01-13 13:25:36 +11:00
|
|
|
|
using Umbraco.Core.Persistence.Repositories;
|
2017-12-07 16:45:25 +01:00
|
|
|
|
using Umbraco.Core.Persistence.Repositories.Implement;
|
2013-02-12 04:13:29 +06:00
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Cache
|
|
|
|
|
|
{
|
2013-03-21 22:53:58 +06:00
|
|
|
|
public sealed class UserCacheRefresher : CacheRefresherBase<UserCacheRefresher>
|
2013-02-12 04:13:29 +06:00
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
public UserCacheRefresher(CacheHelper cacheHelper)
|
|
|
|
|
|
: base(cacheHelper)
|
|
|
|
|
|
{ }
|
2016-05-18 18:44:08 +02:00
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
#region Define
|
2013-03-21 22:53:58 +06:00
|
|
|
|
|
2017-07-11 19:21:13 +02:00
|
|
|
|
protected override UserCacheRefresher This => this;
|
2013-03-21 22:53:58 +06:00
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
public static readonly Guid UniqueId = Guid.Parse("E057AF6D-2EE6-41F4-8045-3694010F0AA6");
|
|
|
|
|
|
|
|
|
|
|
|
public override Guid RefresherUniqueId => UniqueId;
|
|
|
|
|
|
|
|
|
|
|
|
public override string Name => "User Cache Refresher";
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Refresher
|
2013-02-12 04:13:29 +06:00
|
|
|
|
|
2013-03-21 22:53:58 +06:00
|
|
|
|
public override void RefreshAll()
|
2013-02-12 04:13:29 +06:00
|
|
|
|
{
|
2016-01-07 19:27:59 +01:00
|
|
|
|
ClearAllIsolatedCacheByEntityType<IUser>();
|
2014-03-20 12:36:13 +11:00
|
|
|
|
base.RefreshAll();
|
2013-02-12 04:13:29 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-03-21 22:53:58 +06:00
|
|
|
|
public override void Refresh(int id)
|
2013-02-12 04:13:29 +06:00
|
|
|
|
{
|
|
|
|
|
|
Remove(id);
|
2014-03-20 12:36:13 +11:00
|
|
|
|
base.Refresh(id);
|
2013-02-12 04:13:29 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-03-21 22:53:58 +06:00
|
|
|
|
public override void Remove(int id)
|
2013-02-12 04:13:29 +06:00
|
|
|
|
{
|
2016-05-18 18:44:08 +02:00
|
|
|
|
var userCache = CacheHelper.IsolatedRuntimeCache.GetCache<IUser>();
|
2016-01-06 18:08:14 +01:00
|
|
|
|
if (userCache)
|
2017-12-07 16:45:25 +01:00
|
|
|
|
userCache.Result.ClearCacheItem(RepositoryCacheKeys.GetKey<IUser>(id));
|
2017-09-23 10:08:18 +02:00
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
base.Remove(id);
|
2016-01-06 18:08:14 +01:00
|
|
|
|
}
|
2016-05-26 17:12:04 +02:00
|
|
|
|
#endregion
|
2013-02-12 04:13:29 +06:00
|
|
|
|
}
|
2017-07-20 11:21:28 +02:00
|
|
|
|
}
|