Last active
August 18, 2022 08:03
-
-
Save gistlyn/17233b82022695f6af75b4b31068f221 to your computer and use it in GitHub Desktop.
Use ServiceStack.Redis
This file contains hidden or 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
dotnet add package ServiceStack.Redis |
This file contains hidden or 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
using ServiceStack; | |
using ServiceStack.Redis; | |
[assembly: HostingStartup(typeof(MyApp.ConfigureRedis))] | |
namespace MyApp; | |
public class ConfigureRedis : IHostingStartup | |
{ | |
public void Configure(IWebHostBuilder builder) => builder | |
.ConfigureServices((context, services) => { | |
services.AddSingleton<IRedisClientsManager>( | |
new RedisManagerPool(context.Configuration.GetConnectionString("Redis") ?? "localhost:6379")); | |
}) | |
.ConfigureAppHost(appHost => { | |
// Enable built-in Redis Admin UI at /admin-ui/redis | |
// appHost.Plugins.Add(new AdminRedisFeature()); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment