diff --git a/src/Umbraco.Core/Services/IServerRegistrationService.cs b/src/Umbraco.Core/Services/IServerRegistrationService.cs index d5cfd9f7a7..dda0566c7b 100644 --- a/src/Umbraco.Core/Services/IServerRegistrationService.cs +++ b/src/Umbraco.Core/Services/IServerRegistrationService.cs @@ -37,6 +37,17 @@ namespace Umbraco.Cms.Core.Services /// from the database. IEnumerable GetActiveServers(bool refresh = false); + /// + /// Return all servers (active and inactive). + /// + /// A value indicating whether to force-refresh the cache. + /// All servers. + /// By default this method will rely on the repository's cache, which is updated each + /// time the current server is touched, and the period depends on the configuration. Use the + /// parameter to force a cache refresh and reload all servers + /// from the database. + IEnumerable GetServers(bool refresh = false); + /// /// Gets the role of the current server. /// diff --git a/src/Umbraco.Infrastructure/Services/Implement/ServerRegistrationService.cs b/src/Umbraco.Infrastructure/Services/Implement/ServerRegistrationService.cs index 92968510fa..2ab4c0671d 100644 --- a/src/Umbraco.Infrastructure/Services/Implement/ServerRegistrationService.cs +++ b/src/Umbraco.Infrastructure/Services/Implement/ServerRegistrationService.cs @@ -133,13 +133,28 @@ namespace Umbraco.Cms.Core.Services.Implement /// time the current server is touched, and the period depends on the configuration. Use the /// parameter to force a cache refresh and reload active servers /// from the database. - public IEnumerable GetActiveServers(bool refresh = false) + public IEnumerable GetActiveServers(bool refresh = false) => GetServers(refresh).Where(x => x.IsActive); + + /// + /// Return all servers (active and inactive). + /// + /// A value indicating whether to force-refresh the cache. + /// All servers. + /// By default this method will rely on the repository's cache, which is updated each + /// time the current server is touched, and the period depends on the configuration. Use the + /// parameter to force a cache refresh and reload all servers + /// from the database. + public IEnumerable GetServers(bool refresh = false) { using (var scope = ScopeProvider.CreateScope(autoComplete: true)) { scope.ReadLock(Cms.Core.Constants.Locks.Servers); - if (refresh) ((ServerRegistrationRepository) _serverRegistrationRepository).ClearCache(); - return _serverRegistrationRepository.GetMany().Where(x => x.IsActive).ToArray(); // fast, cached // fast, cached + if (refresh) + { + ((ServerRegistrationRepository)_serverRegistrationRepository).ClearCache(); + } + + return _serverRegistrationRepository.GetMany().ToArray(); // fast, cached // fast, cached } }