Skip to content

Instantly share code, notes, and snippets.

@gistlyn
Last active August 18, 2022 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gistlyn/17233b82022695f6af75b4b31068f221 to your computer and use it in GitHub Desktop.
Save gistlyn/17233b82022695f6af75b4b31068f221 to your computer and use it in GitHub Desktop.
Use ServiceStack.Redis
dotnet add package ServiceStack.Redis
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