HangFire持久化数据到Redis

教程:ASP.NET Core MVC上的Redis上的Hangfire

入门

要在ASP.NET Core MVC项目中针对Redis使用Hangfire,首先需要安装至少以下两个软件包:Hangfire.AspNetCoreHangfire.Redis.StackExchange

Startup.cs,这些都是最起码,你将需要编写使迟发型对Redis的代码:

复制代码
public class Startup
{
    

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddHangfire(configuration =>
        {
            configuration.UseRedisStorage("localhost");
        });
    }

    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
        app.UseHangfireServer();
    }
}
复制代码

注意:我这里安装了 Hangfire.Redis.StackExchange.StrongName 这个包才能成功

 

posted @   隔壁家老黄  阅读(3017)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示