Last active
November 13, 2022 15:56
-
-
Save mariusmuntean/b379248abcecba41a6d8be0414f817f1 to your computer and use it in GitHub Desktop.
Create a RedisConnectionProvider instance and add it to the DI container.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void AddRedisOMConnectionProvider(this WebApplicationBuilder webApplicationBuilder) | |
{ | |
var host = webApplicationBuilder.Configuration.GetSection("Redis")["Host"]; | |
var port = webApplicationBuilder.Configuration.GetSection("Redis")["Port"]; | |
var redisConnectionConfiguration = new RedisConnectionConfiguration | |
{ | |
Host = host, | |
Port = Convert.ToInt32(port) | |
}; | |
var redisConnectionProvider = new RedisConnectionProvider(redisConnectionConfiguration); | |
webApplicationBuilder.Services.AddSingleton(redisConnectionProvider); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment