-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
Copy pathMemberGroupCacheRefresher.cs
74 lines (56 loc) · 1.94 KB
/
MemberGroupCacheRefresher.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Serialization;
namespace Umbraco.Cms.Core.Cache
{
public sealed class MemberGroupCacheRefresher : PayloadCacheRefresherBase<MemberGroupCacheRefresherNotification, MemberGroupCacheRefresher.JsonPayload>
{
public MemberGroupCacheRefresher(AppCaches appCaches, IJsonSerializer jsonSerializer, IEventAggregator eventAggregator, ICacheRefresherNotificationFactory factory)
: base(appCaches, jsonSerializer, eventAggregator, factory)
{
}
#region Define
public static readonly Guid UniqueId = Guid.Parse("187F236B-BD21-4C85-8A7C-29FBA3D6C00C");
public override Guid RefresherUniqueId => UniqueId;
public override string Name => "Member Group Cache Refresher";
#endregion
#region Refresher
public override void Refresh(string json)
{
ClearCache();
base.Refresh(json);
}
public override void Refresh(int id)
{
ClearCache();
base.Refresh(id);
}
public override void Remove(int id)
{
ClearCache();
base.Remove(id);
}
private void ClearCache()
{
// Since we cache by group name, it could be problematic when renaming to
// previously existing names - see http://issues.umbraco.org/issue/U4-10846.
// To work around this, just clear all the cache items
AppCaches.IsolatedCaches.ClearCache<IMemberGroup>();
}
#endregion
#region Json
public class JsonPayload
{
public JsonPayload(int id, string name)
{
Id = id;
Name = name;
}
public string Name { get; }
public int Id { get; }
}
#endregion
}
}