# Getting Started
## Storage
Hangfire 會將所有相關資訊會被序列化後保存到儲存區,如類型、方法或參數等。
儲存模型官方預設有以下幾種
|
Sql Server 2008+ |
Redis 2.6.12+ |
In-Memory |
Price |
Open |
✔ |
|
✔ |
free |
Startup |
✔ |
✔ |
✔ |
$500 / per year |
Business |
✔ |
✔ |
✔ |
$1,500 / per year |
Enterprise |
✔ |
✔ |
✔ |
$4,500 / per year |
資料來源日期: 2024/03/12
```
// Hangfire 1.8
GlobalConfiguration
.Configuration
.SetDataCompatibilityLevel(CompatibilityLevel.Version_180)
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UseSqlServerStorage("Database=Hangfire.Sample; Integrated Security=True;");
// Hangfire 1.7
GlobalConfiguration
.Configuration
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UseSqlServerStorage("Database=Hangfire.Sample; Integrated Security=True;", new SqlServerStorageOptions
{
CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
QueuePollInterval = TimeSpan.Zero,
UseRecommendedIsolationLevel = true
});
```