File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
src/Umbraco.Cms.Integrations.Search.Algolia/Handlers Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ using Umbraco . Cms . Core . Cache ;
2+ using Umbraco . Cms . Core . Events ;
3+ using Umbraco . Cms . Core . Notifications ;
4+ using Umbraco . Cms . Core . Sync ;
5+ using Umbraco . Extensions ;
6+
7+ namespace Umbraco . Cms . Integrations . Search . Algolia . Handlers
8+ {
9+ public class AlgoliaContentPublishedHandler : INotificationAsyncHandler < ContentPublishedNotification >
10+ {
11+ private readonly IServerRoleAccessor _serverRoleAccessor ;
12+ private readonly DistributedCache _distributedCache ;
13+
14+ public AlgoliaContentPublishedHandler (
15+ IServerRoleAccessor serverRoleAccessor ,
16+ DistributedCache distributedCache )
17+ {
18+ _serverRoleAccessor = serverRoleAccessor ;
19+ _distributedCache = distributedCache ;
20+ }
21+
22+ public Task HandleAsync ( ContentPublishedNotification notification , CancellationToken cancellationToken )
23+ {
24+ if ( _serverRoleAccessor . CurrentServerRole == ServerRole . SchedulingPublisher )
25+ {
26+ _distributedCache . RefreshAllContentCache ( ) ;
27+ }
28+ return Task . CompletedTask ;
29+ }
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments