Skip to content

Commit 1cb0bfa

Browse files
authored
Merge pull request #286 from umbraco/bugfix/algolia-load-balanced
Trigger memory cache reload on load balanced published
2 parents e1ec3b7 + 4a21aaf commit 1cb0bfa

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed

src/Umbraco.Cms.Integrations.Search.Algolia/AlgoliaComposer.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ public void Compose(IUmbracoBuilder builder)
2323
builder.AddNotificationHandler<UmbracoApplicationStartingNotification, RunAlgoliaIndicesMigration>();
2424

2525
builder.AddNotificationAsyncHandler<ContentCacheRefresherNotification, AlgoliaContentCacheRefresherHandler>();
26-
27-
builder.Services.AddOptions<AlgoliaSettings>()
26+
builder.AddNotificationAsyncHandler<ContentPublishedNotification, AlgoliaContentPublishedHandler>();
27+
28+
builder.Services.AddOptions<AlgoliaSettings>()
2829
.Bind(builder.Config.GetSection(Constants.SettingsPath));
2930

3031
builder.Services.AddSingleton<IAlgoliaIndexService, AlgoliaIndexService>();

src/Umbraco.Cms.Integrations.Search.Algolia/App_Plugins/UmbracoCms.Integrations/Search/Algolia/package.manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Umbraco.Cms.Integrations.Search.Algolia",
3-
"version": "1.3.1",
3+
"version": "2.3.3",
44
"allowPackageTelemetry": true,
55
"javascript": [
66
"~/App_Plugins/UmbracoCms.Integrations/Search/Algolia/js/algolia.service.js",
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
}

src/Umbraco.Cms.Integrations.Search.Algolia/Umbraco.Cms.Integrations.Search.Algolia.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<PackageIconUrl></PackageIconUrl>
1414
<PackageProjectUrl>https://github.com/umbraco/Umbraco.Cms.Integrations/tree/main/src/Umbraco.Cms.Integrations.Search.Algolia</PackageProjectUrl>
1515
<RepositoryUrl>https://github.com/umbraco/Umbraco.Cms.Integrations</RepositoryUrl>
16-
<Version>2.3.2</Version>
16+
<Version>2.3.3</Version>
1717
<Authors>Umbraco HQ</Authors>
1818
<Company>Umbraco</Company>
1919
<PackageTags>Umbraco;Umbraco-Marketplace</PackageTags>

0 commit comments

Comments
 (0)