Skip to content

Instantly share code, notes, and snippets.

@mariusmuntean
Last active November 13, 2022 15:56
Show Gist options
  • Save mariusmuntean/b379248abcecba41a6d8be0414f817f1 to your computer and use it in GitHub Desktop.
Save mariusmuntean/b379248abcecba41a6d8be0414f817f1 to your computer and use it in GitHub Desktop.
Create a RedisConnectionProvider instance and add it to the DI container.
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