2022-08-18 11:14:28 +04:00
|
|
|
|
namespace Microsoft.eShopOnContainers.Services.Basket.API;
|
|
|
|
|
|
|
|
|
|
public static class CustomExtensionMethods
|
|
|
|
|
{
|
2023-05-01 16:31:57 -07:00
|
|
|
|
public static IServiceCollection AddRedis(this IServiceCollection services)
|
|
|
|
|
{
|
2023-05-02 08:00:17 -07:00
|
|
|
|
// {
|
|
|
|
|
// "ConnectionString": "..."
|
|
|
|
|
// }
|
|
|
|
|
|
2023-05-01 16:31:57 -07:00
|
|
|
|
return services.AddSingleton(sp =>
|
|
|
|
|
{
|
|
|
|
|
var settings = sp.GetRequiredService<IOptions<BasketSettings>>().Value;
|
|
|
|
|
var configuration = ConfigurationOptions.Parse(settings.ConnectionString, true);
|
|
|
|
|
|
|
|
|
|
return ConnectionMultiplexer.Connect(configuration);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|