feat: 完成job模块优化

This commit is contained in:
橙子
2025-02-23 01:31:30 +08:00
parent f8a4c737ee
commit f6b19ec2a5
20 changed files with 40 additions and 66 deletions

View File

@@ -0,0 +1,31 @@
using Volo.Abp.BackgroundWorkers.Hangfire;
using Volo.Abp.EventBus.Local;
using Yi.Framework.Bbs.Domain.Shared.Etos;
namespace Yi.Abp.Web.Jobs.bbs;
public class AccessLogCacheJob : HangfireBackgroundWorkerBase
{
private readonly ILocalEventBus _localEventBus;
public AccessLogCacheJob(ILocalEventBus localEventBus)
{
_localEventBus = localEventBus;
RecurringJobId = "访问日志写入缓存";
//每分钟执行一次将本地缓存转入redis防止丢数据
CronExpression = "0 * * * * ?";
//
// JobDetail = JobBuilder.Create<AccessLogCacheJob>().WithIdentity(nameof(AccessLogCacheJob))
// .Build();
//每10秒执行一次将本地缓存转入redis防止丢数据
// Trigger = TriggerBuilder.Create().WithIdentity(nameof(AccessLogCacheJob))
// .WithSimpleSchedule((schedule) => { schedule.WithInterval(TimeSpan.FromSeconds(10)).RepeatForever();; })
// .Build();
}
public override async Task DoWorkAsync(CancellationToken cancellationToken = new CancellationToken())
{
await _localEventBus.PublishAsync(new AccessLogResetArgs());
}
}