diff --git a/src/Digdir.Domain.Dialogporten.Infrastructure/InfrastructureExtensions.cs b/src/Digdir.Domain.Dialogporten.Infrastructure/InfrastructureExtensions.cs index 633bd6976..54a3045d1 100644 --- a/src/Digdir.Domain.Dialogporten.Infrastructure/InfrastructureExtensions.cs +++ b/src/Digdir.Domain.Dialogporten.Infrastructure/InfrastructureExtensions.cs @@ -26,6 +26,7 @@ using Digdir.Domain.Dialogporten.Infrastructure.Altinn.Events; using Digdir.Domain.Dialogporten.Infrastructure.Altinn.OrganizationRegistry; using Digdir.Domain.Dialogporten.Infrastructure.Altinn.ResourceRegistry; +using StackExchange.Redis; namespace Digdir.Domain.Dialogporten.Infrastructure; @@ -59,7 +60,7 @@ public static IServiceCollection AddInfrastructure(this IServiceCollection servi var infrastructureSettings = infrastructureConfigurationSection.Get() ?? throw new InvalidOperationException("Failed to get Redis settings. Infrastructure settings must not be null."); - if (infrastructureSettings.Redis.Enabled) + if (infrastructureSettings.Redis.Enabled == true) { services.AddStackExchangeRedisCache(options => { diff --git a/src/Digdir.Domain.Dialogporten.Infrastructure/InfrastructureSettings.cs b/src/Digdir.Domain.Dialogporten.Infrastructure/InfrastructureSettings.cs index a047f0fd0..65be366ae 100644 --- a/src/Digdir.Domain.Dialogporten.Infrastructure/InfrastructureSettings.cs +++ b/src/Digdir.Domain.Dialogporten.Infrastructure/InfrastructureSettings.cs @@ -29,7 +29,7 @@ public sealed class AltinnCdnPlatformSettings public sealed class RedisSettings { - public required bool Enabled { get; init; } + public required bool? Enabled { get; init; } public required string ConnectionString { get; init; } } @@ -93,7 +93,7 @@ internal sealed class RedisSettingsValidator : AbstractValidator { public RedisSettingsValidator() { - RuleFor(x => x.Enabled).NotEmpty(); + RuleFor(x => x.Enabled).Must(x => x is false or true); RuleFor(x => x.ConnectionString).NotEmpty(); } } \ No newline at end of file diff --git a/src/Digdir.Domain.Dialogporten.WebApi/appsettings.Development.json b/src/Digdir.Domain.Dialogporten.WebApi/appsettings.Development.json index dcdf1935f..c3d1a6e98 100644 --- a/src/Digdir.Domain.Dialogporten.WebApi/appsettings.Development.json +++ b/src/Digdir.Domain.Dialogporten.WebApi/appsettings.Development.json @@ -6,9 +6,9 @@ } }, "Infrastructure": { - "Redis":{ - "Enabled": false, - "ConnectionString": "redis://localhost:6379" + "Redis": { + "Enabled": true, + "ConnectionString": "localhost:6379" }, "DialogDbConnectionString": "TODO: Add to local secrets", // Settings from appsettings.json, environment variables or other configuration providers.