2021-03-15 13:39:34 +11:00
|
|
|
using System;
|
2021-03-12 21:48:24 +01:00
|
|
|
using Umbraco.Cms.Core.Events;
|
2021-02-18 11:06:02 +01:00
|
|
|
using Umbraco.Cms.Core.Models.Membership;
|
2021-05-11 14:33:49 +02:00
|
|
|
using Umbraco.Cms.Core.Notifications;
|
2021-02-18 11:06:02 +01:00
|
|
|
using Umbraco.Cms.Core.Persistence.Repositories;
|
2018-06-29 19:52:40 +02:00
|
|
|
|
2021-02-18 11:06:02 +01:00
|
|
|
namespace Umbraco.Cms.Core.Cache
|
2018-06-29 19:52:40 +02:00
|
|
|
{
|
2021-03-12 21:48:24 +01:00
|
|
|
public sealed class UserCacheRefresher : CacheRefresherBase<UserCacheRefresherNotification>
|
2018-06-29 19:52:40 +02:00
|
|
|
{
|
2021-03-15 13:39:34 +11:00
|
|
|
public UserCacheRefresher(AppCaches appCaches, IEventAggregator eventAggregator, ICacheRefresherNotificationFactory factory)
|
|
|
|
|
: base(appCaches, eventAggregator, factory)
|
2018-06-29 19:52:40 +02:00
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
#region Define
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
public override void RefreshAll()
|
|
|
|
|
{
|
|
|
|
|
ClearAllIsolatedCacheByEntityType<IUser>();
|
|
|
|
|
base.RefreshAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Refresh(int id)
|
|
|
|
|
{
|
|
|
|
|
Remove(id);
|
|
|
|
|
base.Refresh(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Remove(int id)
|
|
|
|
|
{
|
2019-01-17 11:01:23 +01:00
|
|
|
var userCache = AppCaches.IsolatedCaches.Get<IUser>();
|
2022-02-09 13:24:35 +01:00
|
|
|
if (userCache.Success)
|
2021-02-09 13:43:28 +11:00
|
|
|
{
|
2022-01-13 09:27:37 +01:00
|
|
|
userCache.Result?.Clear(RepositoryCacheKeys.GetKey<IUser, int>(id));
|
|
|
|
|
userCache.Result?.ClearByKey(CacheKeys.UserContentStartNodePathsPrefix + id);
|
|
|
|
|
userCache.Result?.ClearByKey(CacheKeys.UserMediaStartNodePathsPrefix + id);
|
|
|
|
|
userCache.Result?.ClearByKey(CacheKeys.UserAllContentStartNodesPrefix + id);
|
|
|
|
|
userCache.Result?.ClearByKey(CacheKeys.UserAllMediaStartNodesPrefix + id);
|
2021-02-09 13:43:28 +11:00
|
|
|
}
|
2021-03-12 21:48:24 +01:00
|
|
|
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
|
|
|
base.Remove(id);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|