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

猜你喜欢

转载自www.cnblogs.com/yhnx/p/9186140.html