fix hangfire切换到redis
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
using Hangfire;
|
||||
using Hangfire.Dashboard.BasicAuthorization;
|
||||
using Hangfire.MySql;
|
||||
using Hangfire.Redis.StackExchange;
|
||||
using Kurisu.AspNetCore.Startup;
|
||||
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Packs;
|
||||
|
||||
@@ -14,16 +14,15 @@ public class HangfirePack : BaseAppPack
|
||||
|
||||
public override void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddHangfire(configuration =>
|
||||
services.AddHangfire((sp, config) =>
|
||||
{
|
||||
var options = new MySqlStorageOptions
|
||||
{
|
||||
TablesPrefix = "hangfire"
|
||||
};
|
||||
|
||||
configuration.UseSimpleAssemblyNameTypeSerializer()
|
||||
config.UseSimpleAssemblyNameTypeSerializer()
|
||||
.UseRecommendedSerializerSettings()
|
||||
.UseStorage(new MySqlStorage(Configuration.GetConnectionString("HangfireConnection"), options));
|
||||
.UseRedisStorage(sp.GetService<IConnectionMultiplexer>(), new RedisStorageOptions
|
||||
{
|
||||
Db = 5,
|
||||
Prefix = "hangfire"
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user