Skip to content

Commit

Permalink
Using Redis with sentinels OrchardCMS#11617
Browse files Browse the repository at this point in the history
  • Loading branch information
mazuryv committed May 5, 2022
1 parent 9e20859 commit 6af7f17
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/OrchardCore.Modules/OrchardCore.Redis/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,23 @@ public Startup(ShellSettings shellSettings, IShellConfiguration configuration, I

public override void ConfigureServices(IServiceCollection services)
{
var originalConfigurationString = _configuration["OrchardCore_Redis:Configuration"];
var instancePrefix = _configuration["OrchardCore_Redis:InstancePrefix"];

if (string.IsNullOrEmpty(originalConfigurationString))
try
{
_logger.LogError("'Redis' features are not active on tenant '{TenantName}' as the 'Configuration' string is missing", _tenant);
return;
var configurationString = _configuration["OrchardCore_Redis:Configuration"];
var _ = ConfigurationOptions.Parse(configurationString);
var instancePrefix = _configuration["OrchardCore_Redis:InstancePrefix"];

services.Configure<RedisOptions>(options =>
{
options.Configuration = configurationString;
options.InstancePrefix = instancePrefix;
});
}
services.Configure<RedisOptions>(options =>
catch (Exception e)
{
options.Configuration = originalConfigurationString;
options.InstancePrefix = instancePrefix;
});
_logger.LogError("'Redis' features are not active on tenant '{TenantName}' as the 'Configuration' string is missing or invalid: " + e.Message, _tenant);
return;
}

services.AddSingleton<IRedisService, RedisService>();
services.AddSingleton<IModularTenantEvents>(sp => sp.GetRequiredService<IRedisService>());
Expand Down

0 comments on commit 6af7f17

Please sign in to comment.