Last active
June 22, 2019 21:16
-
-
Save gistlyn/512309b3cb7d734bb0f7323907499b08 to your computer and use it in GitHub Desktop.
Use ServiceStack.Redis
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
dotnet add package ServiceStack.Redis |
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
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.DependencyInjection; | |
using ServiceStack; | |
using ServiceStack.Redis; | |
namespace MyApp | |
{ | |
public class ConfigureRedis : IConfigureServices, IConfigureAppHost | |
{ | |
IConfiguration Configuration { get; } | |
public ConfigureRedis(IConfiguration configuration) => Configuration = configuration; | |
public void Configure(IServiceCollection services) | |
{ | |
services.AddSingleton<IRedisClientsManager>( | |
new RedisManagerPool(Configuration.GetConnectionString("Redis") ?? "localhost:6379")); | |
} | |
public void Configure(IAppHost appHost) | |
{ | |
appHost.GetPlugin<SharpPagesFeature>()?.ScriptMethods.Add(new RedisScripts()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment