要在ASP.NET Core MVC項目中針對Redis使用Hangfire,首先須要安裝至少如下兩個軟件包:Hangfire.AspNetCore
和Hangfire.Redis.StackExchange
。git
在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