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 4, 2022
1 parent 2192704 commit 9e20859
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
22 changes: 10 additions & 12 deletions src/OrchardCore.Modules/OrchardCore.Redis/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,20 @@ public Startup(ShellSettings shellSettings, IShellConfiguration configuration, I

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

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

}
services.Configure<RedisOptions>(options =>
{
options.Configuration = originalConfigurationString;
options.InstancePrefix = instancePrefix;
});

services.AddSingleton<IRedisService, RedisService>();
services.AddSingleton<IModularTenantEvents>(sp => sp.GetRequiredService<IRedisService>());
Expand Down
10 changes: 5 additions & 5 deletions src/OrchardCore/OrchardCore.Redis.Abstractions/RedisOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

namespace OrchardCore.Redis
{
/// <summary>
/// Redis options.
/// </summary>
public class RedisOptions
{
/// <summary>
/// The configuration used to connect to Redis.
/// </summary>
public ConfigurationOptions ConfigurationOptions { get; set; }

public ConfigurationOptions ConfigurationOptions => ConfigurationOptions.Parse(Configuration);
/// <summary>
/// Original configuration string used to connect to Redis
/// </summary>
public string Configuration { get; set; }
/// <summary>
/// Prefix alowing a Redis instance to be shared.
/// </summary>
Expand Down

0 comments on commit 9e20859

Please sign in to comment.