Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: minor refactor #583

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ public static IServiceCollection AddInfrastructure(this IServiceCollection servi
services.AddDistributedMemoryCache();
}

ConfigureFusionCache(services, nameof(Altinn.NameRegistry), new()
services.ConfigureFusionCache(nameof(Altinn.NameRegistry), new()
{
Duration = TimeSpan.FromDays(1),
});
ConfigureFusionCache(services, nameof(Altinn.ResourceRegistry), new()
})
.ConfigureFusionCache(nameof(Altinn.ResourceRegistry), new()
{
Duration = TimeSpan.FromMinutes(20),
});
ConfigureFusionCache(services, nameof(Altinn.OrganizationRegistry), new()
})
.ConfigureFusionCache(nameof(Altinn.OrganizationRegistry), new()
{
Duration = TimeSpan.FromDays(1),
});
Expand Down Expand Up @@ -196,11 +196,11 @@ private static IHttpClientBuilder AddMaskinportenHttpClient<TClient, TImplementa
.AddMaskinportenHttpMessageHandler<TClientDefinition, TClient>(configureClientDefinition);
}

private static void ConfigureFusionCache(IServiceCollection services, string cacheName, FusionCacheSettings? settings = null)
private static IServiceCollection ConfigureFusionCache(this IServiceCollection services, string cacheName, FusionCacheSettings? settings = null)
{
settings ??= new FusionCacheSettings();

var fusionCacheConfig = services.AddFusionCache(cacheName)
services.AddFusionCache(cacheName)
.WithOptions(options =>
{
options.DistributedCacheCircuitBreakerDuration = TimeSpan.FromSeconds(2);
Expand All @@ -227,5 +227,7 @@ private static void ConfigureFusionCache(IServiceCollection services, string cac
.WithRegisteredSerializer()
.WithRegisteredDistributedCache()
.WithRegisteredBackplane();

return services;
}
}