我有一個控制檯應用程序來測試HangFire。下面是代碼:有沒有Hangfire的內存作業存儲包?
using System;
using Hangfire;
namespace MyScheduler.ConsoleApp
{
internal static class Program
{
internal static void Main(string[] args)
{
MyMethod();
Console.WriteLine("[Finished]");
Console.ReadKey();
}
private static void MyMethod()
{
RecurringJob.AddOrUpdate(() => Console.Write("Easy!"), Cron.Minutely);
}
}
}
但它在運行時拋出異常:
其他信息:JobStorage.Current屬性值一直沒有 初始化。您必須在使用Hangfire客戶端或服務器的API之前將其設置。
所以我需要一個作業存儲來運行這個。但在SQL存儲等所有例子是否有任何方式來運行此示例與某種內存存儲?
JobStorage.Current = new SqlServerStorage("ConnectionStringName", options);
// to
JobStorage.Current = new MemoryDbStorage(string.Empty, options);
您是否嘗試過搜索「Hangfire內存」的Google搜索?我在10秒內找到了你的問題的答案。即使您決定不適合您,也有其他很多易於設置的選項,例如SQL Server LocalDB,SQLite和Mongo。 – mason
我更新了我的問題。而且文件也應該更新。祝你今天愉快。 –
NuGet的搜索功能不太好。使用Google/Bing。無論如何,沒有必要告訴我們*關於文件。您可以提交拉取請求來更新它或在其[GitHub](https://github.com/HangfireIO/Hangfire-Documentation)上提出問題。無論如何,我認爲他們的文檔沒有問題。如果你讀過它,「Hangfire.Core就足夠了」顯然是指不安裝主要的「Hangfire」包,它具有控制檯應用程序不需要的依賴關係。並且在上面它清楚地陳述您需要工作存儲包裹。我很清楚。 – mason