Learn.VideoAnalysis/VideoAnalysis/Expand/CoravelExpand.cs

40 lines
1.2 KiB
C#

using Coravel;
using Coravel.Scheduling.Schedule;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VideoAnalysisCore.Job;
namespace Learn.VideoAnalysis.Expand
{
public static class CoravelExpand
{
public static void AddCoravel(this IServiceCollection service)
{
Console.WriteLine($"{DateTime.Now}=>初始化 Coravel");
service.AddScheduler();
#if !DEBUG
service.AddTransient<TaskFileClearJob>();
#endif
service.AddTransient<ClearAllCacheJob>();
service.AddTransient<NodePackageJob>();
}
public static void UseCoravelExpand(this IApplicationBuilder provider)
{
provider.ApplicationServices.UseScheduler(scheduler =>
{
//任务缓存清理
// scheduler.Schedule<TaskFileClearJob>().HourlyAt(10);
//强制清理所有缓存内容
//scheduler.Schedule<ClearAllCacheJob>().Hourly();
scheduler.Schedule<ClearAllCacheJob>().EverySeconds(40);
});
}
}
}