-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use CacheRefreshers for load balancing setup (#222)
- Loading branch information
1 parent
4213d2c
commit d8d9c11
Showing
19 changed files
with
259 additions
and
27 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/SeoToolkit.Umbraco.Common.Core/Caching/SeoSettingsCacheRefresher.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using SeoToolkit.Umbraco.Common.Core.Constants; | ||
using System; | ||
using System.Security.Policy; | ||
using Umbraco.Cms.Core.Cache; | ||
using Umbraco.Cms.Core.Events; | ||
|
||
namespace SeoToolkit.Umbraco.Common.Core.Caching | ||
{ | ||
public sealed class SeoSettingsCacheRefresher : CacheRefresherBase<SeoSettingsCacheRefresherNotification> | ||
{ | ||
public static Guid CacheGuid = new("835839b0-457a-4a02-b5c8-3f8cfec5e350"); | ||
|
||
public override Guid RefresherUniqueId => CacheGuid; | ||
public override string Name => "Seo Settings Cache Refresher"; | ||
|
||
public SeoSettingsCacheRefresher(AppCaches appCaches, IEventAggregator eventAggregator, ICacheRefresherNotificationFactory factory) : base(appCaches, eventAggregator, factory) | ||
{ | ||
} | ||
|
||
public override void Refresh(int id) | ||
{ | ||
AppCaches.RuntimeCache.ClearByKey($"{CacheConstants.SeoSettings}{id}"); | ||
base.Refresh(id); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/SeoToolkit.Umbraco.Common.Core/Caching/SeoSettingsCacheRefresherNotification.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Umbraco.Cms.Core.Notifications; | ||
using Umbraco.Cms.Core.Sync; | ||
|
||
namespace SeoToolkit.Umbraco.Common.Core.Caching | ||
{ | ||
public class SeoSettingsCacheRefresherNotification : CacheRefresherNotification | ||
{ | ||
public SeoSettingsCacheRefresherNotification(object messageObject, MessageType messageType) : base(messageObject, messageType) | ||
{ | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/SeoToolkit.Umbraco.Common.Core/Constants/CacheConstants.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace SeoToolkit.Umbraco.Common.Core.Constants | ||
{ | ||
static internal class CacheConstants | ||
{ | ||
public const string SeoSettings = "SeoSettingsService_"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/SeoToolkit.Umbraco.MetaFields.Core/Caching/DocumentTypeSettingsCacheRefresher.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using NPoco; | ||
using SeoToolkit.Umbraco.MetaFields.Core.Constants; | ||
using System; | ||
using Umbraco.Cms.Core.Cache; | ||
using Umbraco.Cms.Core.Events; | ||
|
||
namespace SeoToolkit.Umbraco.MetaFields.Core.Caching | ||
{ | ||
public sealed class DocumentTypeSettingsCacheRefresher : CacheRefresherBase<DocumentTypeSettingsCacheRefresherNotification> | ||
{ | ||
public static Guid CacheGuid = new("6ffa6a98-95d3-4060-bcfb-63be3875da0c"); | ||
|
||
public override Guid RefresherUniqueId => CacheGuid; | ||
|
||
public override string Name => "Document Type Settings Cache Refresher"; | ||
|
||
public DocumentTypeSettingsCacheRefresher(AppCaches appCaches, IEventAggregator eventAggregator, ICacheRefresherNotificationFactory factory) : base(appCaches, eventAggregator, factory) | ||
{ | ||
} | ||
|
||
public override void Refresh(int id) | ||
{ | ||
AppCaches.RuntimeCache.ClearByKey($"{CacheConstants.DocumentTypeSettings}{id}"); | ||
base.Refresh(id); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...Toolkit.Umbraco.MetaFields.Core/Caching/DocumentTypeSettingsCacheRefresherNotification.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Umbraco.Cms.Core.Notifications; | ||
using Umbraco.Cms.Core.Sync; | ||
|
||
namespace SeoToolkit.Umbraco.MetaFields.Core.Caching | ||
{ | ||
public class DocumentTypeSettingsCacheRefresherNotification : CacheRefresherNotification | ||
{ | ||
public DocumentTypeSettingsCacheRefresherNotification(object messageObject, MessageType messageType) : base(messageObject, messageType) | ||
{ | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/SeoToolkit.Umbraco.MetaFields.Core/Caching/SeoValueCacheRefresher.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using SeoToolkit.Umbraco.MetaFields.Core.Constants; | ||
using System; | ||
using Umbraco.Cms.Core.Cache; | ||
using Umbraco.Cms.Core.Events; | ||
|
||
namespace SeoToolkit.Umbraco.MetaFields.Core.Caching | ||
{ | ||
public class SeoValueCacheRefresher : CacheRefresherBase<SeoValueCacheRefresherNotification> | ||
{ | ||
public static Guid CacheGuid = new("bf0f9b10-f56d-4385-9d48-0732c8e76846"); | ||
|
||
public override Guid RefresherUniqueId => CacheGuid; | ||
public override string Name => "Seo Value Cache Refresher"; | ||
|
||
public SeoValueCacheRefresher(AppCaches appCaches, IEventAggregator eventAggregator, ICacheRefresherNotificationFactory factory) : base(appCaches, eventAggregator, factory) | ||
{ | ||
} | ||
|
||
public override void Refresh(int id) | ||
{ | ||
AppCaches.RuntimeCache.ClearByKey($"{CacheConstants.SeoValue}{id}"); | ||
base.Refresh(id); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/SeoToolkit.Umbraco.MetaFields.Core/Caching/SeoValueCacheRefresherNotification.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Umbraco.Cms.Core.Notifications; | ||
using Umbraco.Cms.Core.Sync; | ||
|
||
namespace SeoToolkit.Umbraco.MetaFields.Core.Caching | ||
{ | ||
public class SeoValueCacheRefresherNotification : CacheRefresherNotification | ||
{ | ||
public SeoValueCacheRefresherNotification(object messageObject, MessageType messageType) : base(messageObject, messageType) | ||
{ | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/SeoToolkit.Umbraco.MetaFields.Core/Constants/CacheConstants.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace SeoToolkit.Umbraco.MetaFields.Core.Constants | ||
{ | ||
internal class CacheConstants | ||
{ | ||
public const string DocumentTypeSettings = "DocumentTypeSettings_"; | ||
public const string SeoValue = "SeoValueService_"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/SeoToolkit.Umbraco.Redirects.Core/Caching/RedirectsCacheRefresher.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using SeoToolkit.Umbraco.Redirects.Core.Constants; | ||
using System; | ||
using Umbraco.Cms.Core.Cache; | ||
using Umbraco.Cms.Core.Events; | ||
|
||
namespace SeoToolkit.Umbraco.Redirects.Core.Caching | ||
{ | ||
public sealed class RedirectsCacheRefresher : CacheRefresherBase<RedirectsCacheRefresherNotification> | ||
{ | ||
public static Guid CacheGuid = new("3c46284f-3fad-49fe-9cad-f436f0762c5d"); | ||
|
||
public override Guid RefresherUniqueId => CacheGuid; | ||
public override string Name => "Redirects Cache Refresher"; | ||
|
||
public RedirectsCacheRefresher(AppCaches appCaches, IEventAggregator eventAggregator, ICacheRefresherNotificationFactory factory) : base(appCaches, eventAggregator, factory) | ||
{ | ||
} | ||
|
||
public override void RefreshAll() | ||
{ | ||
AppCaches.RuntimeCache.ClearByKey(CacheConstants.Redirects); | ||
base.RefreshAll(); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/SeoToolkit.Umbraco.Redirects.Core/Caching/RedirectsCacheRefresherNotification.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Umbraco.Cms.Core.Notifications; | ||
using Umbraco.Cms.Core.Sync; | ||
|
||
namespace SeoToolkit.Umbraco.Redirects.Core.Caching | ||
{ | ||
public class RedirectsCacheRefresherNotification : CacheRefresherNotification | ||
{ | ||
public RedirectsCacheRefresherNotification(object messageObject, MessageType messageType) : base(messageObject, messageType) | ||
{ | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/SeoToolkit.Umbraco.Redirects.Core/Constants/CacheConstants.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace SeoToolkit.Umbraco.Redirects.Core.Constants | ||
{ | ||
static internal class CacheConstants | ||
{ | ||
public const string Redirects = "redirects_"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/SeoToolkit.Umbraco.ScriptManager.Core/Caching/ScriptManagerCacheRefresher.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using SeoToolkit.Umbraco.ScriptManager.Core.Constants; | ||
using System; | ||
using Umbraco.Cms.Core.Cache; | ||
using Umbraco.Cms.Core.Events; | ||
|
||
namespace SeoToolkit.Umbraco.ScriptManager.Core.Caching | ||
{ | ||
public sealed class ScriptManagerCacheRefresher : CacheRefresherBase<ScriptManagerCacheRefresherNotification> | ||
{ | ||
public static Guid CacheGuid = new("70b9222a-db9c-4da3-9c3a-63a8174cf6d8"); | ||
|
||
public override Guid RefresherUniqueId => CacheGuid; | ||
public override string Name => "Script Manager Cache Refresher"; | ||
|
||
public ScriptManagerCacheRefresher(AppCaches appCaches, IEventAggregator eventAggregator, ICacheRefresherNotificationFactory factory) : base(appCaches, eventAggregator, factory) | ||
{ | ||
} | ||
|
||
public override void RefreshAll() | ||
{ | ||
AppCaches.RuntimeCache.ClearByKey(CacheConstants.ScriptManager); | ||
base.RefreshAll(); | ||
} | ||
} | ||
} |
Oops, something went wrong.