HangFire持久化数据到Redis

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

入门

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

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

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 这个包才能成功app

相关文章
相关标签/搜索