![]() |
VOOZH | about |
dotnet add package Hangfire.Redis.StackExchange --version 1.12.0
NuGet\Install-Package Hangfire.Redis.StackExchange -Version 1.12.0
<PackageReference Include="Hangfire.Redis.StackExchange" Version="1.12.0" />
<PackageVersion Include="Hangfire.Redis.StackExchange" Version="1.12.0" />Directory.Packages.props
<PackageReference Include="Hangfire.Redis.StackExchange" />Project file
paket add Hangfire.Redis.StackExchange --version 1.12.0
#r "nuget: Hangfire.Redis.StackExchange, 1.12.0"
#:package Hangfire.Redis.StackExchange@1.12.0
#addin nuget:?package=Hangfire.Redis.StackExchange&version=1.12.0Install as a Cake Addin
#tool nuget:?package=Hangfire.Redis.StackExchange&version=1.12.0Install as a Cake Tool
HangFire Redis storage based on HangFire.Redis but using lovely StackExchange.Redis client.
| Package Name | NuGet.org |
|---|---|
Hangfire.Redis.StackExchange |
👁 Nuget Badge |
Hangfire.Redis.StackExchange.StrongName |
👁 Nuget Badge |
Despite the name,
Hangfire.Redis.StackExchange.StrongNameis not signed becauseHangfire.Coreis not yet signed.
To use Hangfire against Redis in an ASP.NET Core MVC projects, first you will need to install at least these two packages: Hangfire.AspNetCore and Hangfire.Redis.StackExchange.
In Startup.cs, these are the bare minimum codes that you will need to write for enabling Hangfire on Redis:
public class Startup
{
public static ConnectionMultiplexer Redis;
public Startup(IHostingEnvironment env)
{
// Other codes / configurations are omitted for brevity.
Redis = ConnectionMultiplexer.Connect(Configuration.GetConnectionString("Redis"));
}
public void ConfigureServices(IServiceCollection services)
{
services.AddHangfire(configuration =>
{
configuration.UseRedisStorage(Redis);
});
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.UseHangfireServer();
}
}
Attention: If you are using
Microsoft.Extensions.Caching.Redispackage, you will need to useHangfire.Redis.StackExchange.StrongNameinstead, because the former package requiresStackExchange.Redis.StrongNameinstead ofStackExchange.Redis!
This method accepts two parameters:
The first parameter accepts either your Redis connection string or a ConnectionMultiplexer object. By recommendation of the official StackExchange.Redis documentation, it is actually recommended to create one ConnectionMultiplexer for multiple reuse.
The second parameter accepts RedisStorageOptions object. As of version 1.7.0, these are the properties you can set into the said object:
namespace Hangfire.Redis
{
public class RedisStorageOptions
{
public const string DefaultPrefix = "{hangfire}:";
public RedisStorageOptions();
public TimeSpan InvisibilityTimeout { get; set; }
public TimeSpan FetchTimeout { get; set; }
public string Prefix { get; set; }
public int Db { get; set; }
public int SucceededListSize { get; set; }
public int DeletedListSize { get; set; }
}
}
It is highly recommended to set the Prefix property, to avoid overlap with other projects that targets the same Redis store!
This method accepts BackgroundJobServerOptions as the first parameter:
namespace Hangfire
{
public class BackgroundJobServerOptions
{
public BackgroundJobServerOptions();
public string ServerName { get; set; }
public int WorkerCount { get; set; }
public string[] Queues { get; set; }
public TimeSpan ShutdownTimeout { get; set; }
public TimeSpan SchedulePollingInterval { get; set; }
public TimeSpan HeartbeatInterval { get; set; }
public TimeSpan ServerTimeout { get; set; }
public TimeSpan ServerCheckInterval { get; set; }
public IJobFilterProvider FilterProvider { get; set; }
public JobActivator Activator { get; set; }
}
}
Of these options, several interval options may be manually set (to longer intervals) to reduce CPU load:
SchedulePollingInterval is by default set to 15 seconds.
HeartbeatInterval is by default set to 30 seconds.
ServerTimeout and ServerCheckInterval is by default set to 5 minutes.
Written below is a short snippet on how to implement Hangfire dashboard in ASP.NET Core MVC applications, with limited access to cookie-authenticated users of Administrator role. Read more in official documentation.
public class AdministratorHangfireDashboardAuthorizationFilter : IDashboardAuthorizationFilter
{
public bool Authorize(DashboardContext context)
{
var user = context.GetHttpContext().User;
return user.Identity.IsAuthenticated && user.IsInRole("Administrator");
}
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.UseCookieAuthentication(...);
// This middleware must be placed AFTER the authentication middlewares!
app.UseHangfireDashboard(options: new DashboardOptions
{
Authorization = new[] { new AdministratorHangfireDashboardAuthorizationFilter() }
});
}
For cleaner and more managable application code, it is possible to define your jobs in a class that is registered via dependency injection.
public class MyHangfireJobs
{
public async Task SendGetRequest()
{
var client = new HttpClient();
await client.GetAsync("https://www.accelist.com");
}
}
public void ConfigureServices(IServiceCollection services)
{
services.AddTransient<MyHangfireJobs>();
}
Using this technique, the registered jobs service will be able to obtain other services as dependency via constructor parameters, such as Entity Framework Core DbContext; which enables the development of powerful jobs with relative ease.
Then later you can execute the jobs using generic expression:
BackgroundJob.Enqueue<MyHangfireJobs>(jobs => jobs.SendGetRequest());
BackgroundJob.Schedule<MyHangfireJobs>(jobs => jobs.SendGetRequest(), DateTimeOffset.UtcNow.AddDays(1));
RecurringJob.AddOrUpdate<MyHangfireJobs>("RecurringSendGetRequest", jobs => jobs.SendGetRequest(), Cron.Hourly());
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on Hangfire.Redis.StackExchange:
| Package | Downloads |
|---|---|
|
PiratesCore
湖南医标通信息科技有限公司 |
|
|
EaCloud.Hangfire
EaCloud Hangfire 后台任务组件,封装基于 Hangfire 后台任务的服务端实现。 |
|
|
Bit.Server.Hangfire
Bit.Server.Hangfire |
|
|
Eaf.Middleware.Web.Core
Enterprise Application Foundation - Module Middleware - WebCore Classes |
|
|
Bit.Hangfire
Bit.Hangfire |
Showing the top 12 popular GitHub repositories that depend on Hangfire.Redis.StackExchange:
| Repository | Stars |
|---|---|
|
CoreUnion/CoreShop
基于 Asp.Net Core 9.0、Uni-App开发,支持可视化布局的小程序商城系统,前后端分离,支持分布式部署,跨平台运行,拥有分销、代理、团购、拼团、秒杀、直播、优惠券、自定义表单等众多营销功能,拥有完整SKU、下单、售后、物流流程。支持一套代码编译发布微信小程序版、H5版、Android版、iOS版、支付宝小程序版、字节跳动小程序版、QQ小程序版等共10个平台。
|
|
|
bitfoundation/bitplatform
Build all of your apps using what you already know and love ❤️
|
|
|
colinin/abp-next-admin
这是基于vue-vben-admin 模板适用于abp vNext的前端管理项目
|
|
|
trueai-org/module-shop
一个基于 .NET 8.0 构建的简单、跨平台、模块化的商城系统
|
|
|
q315523275/FamilyBucket
集合.net core、ocelot、consul、netty、rpc、eventbus、configserver、tracing、sqlsugar、vue-admin、基础管理平台等构建的微服务一条龙应用
|
|
|
junkai-li/NetCoreKevin
🤖基于.NET搭建的企业级中台AI知识库智能体开源架构:Skills技能管理、AI-Qdrant知识库、知识库重排模型、AI联网搜索、多智能体协同、聊天记录压缩策略、智能体权限管控、AgentFramework、RAG检索增强、本地Ollama AI模型调用、智能体技能可控加载、领域事件、一库多租户、Log4、Jwt、CAP、SignalR、Mcp、Ioc、Hangfire、RabbitMQ、Xunit、前端(Vue + Ant Design)
|
|
|
volodymyrsmirnov/MalwareMultiScan
Self-hosted VirusTotal / MetaDefender wannabe with API, demo UI and Scanners running in Docker.
|
|
| sd797994/Oxygen-Dapr.EshopSample | |
|
gnsilence/HangfireHttpJob
hangfire的拓展程序,在原作者基础上增加了一些功能,调用api的方式来执行定时任务
|
|
|
jxnkwlp/abp-elsa-module
Elsa abp module and workflow app
|
|
|
face-it/Hangfire.Tags
Add tags to Hangfire backgroundjobs
|
|
|
netcorepal/d3shop
An online shop project based on Domain-Driven Design
|
| Version | Downloads | Last Updated |
|---|---|---|
| 1.12.0 | 1,539,928 | 3/28/2025 |
| 1.11.0 | 55,546 | 3/24/2025 |
| 1.10.1-beta2 | 580,141 | 6/18/2024 |
| 1.10.1-beta | 20,822 | 6/18/2024 |
| 1.9.4 | 778,535 | 11/12/2024 |
| 1.9.4-beta.1 | 9,094 | 1/16/2024 |
| 1.9.4-beta | 50,012 | 7/21/2023 |
| 1.9.3 | 2,280,424 | 11/16/2023 |
| 1.9.3-beta | 10,330 | 5/10/2023 |
| 1.9.2 | 94,097 | 10/26/2023 |
| 1.9.1-beta | 6,923 | 10/7/2022 |
| 1.9.0 | 1,001,197 | 6/5/2023 |
| 1.9.0-beta | 2,258 | 7/18/2022 |
| 1.8.7 | 392,553 | 3/8/2023 |
| 1.8.6 | 902,897 | 9/30/2022 |
| 1.8.5 | 1,419,245 | 10/17/2021 |
| 1.8.4 | 2,184,847 | 5/28/2020 |
1.12.0 Fix #153 and all the chaneg
- Resume all changes between 1after 1.9.3 4 , realigning the codegit
- Bump Hangfire to 1.8.12 and StackExchange.Redis to 2.7.33
1.11.0 Fix #157 AND bring back the code from 1.9.4
With this release I'm trying to start back from 1.9.4 (Latest release "approved for production" as 1.9.5 got unlisted) and I'm willing to review and recommit the code from there. One commit after the other.
If anyone can help with testing, please drop a line to marco.casamento@gmail.com
1.10.1-Beta2
- Fix #153 Appeared after 1.10.0 release. Only updates to this version for testing purposes and PLEASE report any issues. Stick to 1.9.3 for production.
1.10.0
- Fix #135 -CHANGED BEHAVIOR- Library now requeue jobs from dead server (read comments in the issue) thanks to @Lexy2
- Implement #150 (Replace async Redis calls with sync ones) thanks to @Lexy2
- Fix #148 (Can't schedule a job without specifying the queue ) thanks to @Lexy2
- Fix #142 (Scheduled jobs are returned incorrectly by the monitoring API) thanks to @Lexy2
1.9.5 ---UNLISTED----
- Address #139 support for netstandard2.0
- Fix #145 Added Job Queue parameter to the job information
- Update to Hangfire 1.8.12 and StackExchange.Redis 2.7.33
Big thanks to @Lexy2 for all the work on this release
1.9.4
- Update to Hangfire 1.8.7
- Add Support for all features defined for the storage in Hangfire 1.8.7
- Update StackExchange.Redis to 2.7.10
1.9.3
- Fix the missing key prefixing ({hangfire}:) for GetSetCount and GetSetContains (thanks to BobSilent)
1.9.2
- Failed jobs page lists new items first (thanks to toddlucas)
1.9.1
- Downgrade to netStandard 2.0 for broader compatibility
1.9
- Switched AsyncLocal storage of redis lock to ThreadLocal
- BREAKING CHANGE: Drop support for net461
- Added compatibility to Hangfire.Core 1.8
- BREAKING CHANGE: Namespace changes to uniform with folders (It wrongly appeared in previous ver)
1.8.5
- Speed up Recurring jobs Fetching (thanks to developingjim)
1.8.4
- Fix #90, #91 concurrent access on dictinoary (thanks to luukholleman)
- Fix #94 occasional error in monitoringApi (thanks to tsu1980)
1.8.3
- Removed dependency to NewtonSoft.JSON (thanks to neyromant)
1.8.2
- Updated Hangfire to 1.7.11 (thanks to abarducci)
- Updated StackExchange.Redis to 2.1.30 (thanks to abarducci)
1.8.1
- Updated Hangfire to 1.7.8
- Fixed #82 (thanks to @bcuff)
1.8.0
- Updated StackExchange.Redis to 2.0 (thanks to @andrebires)
1.7.2
- Added support for Lifo Queues (thanks to AndreSteenbergen)
- Added option to not use transaction (thanks to AndreSteenbergen)
- Enabled sliding expiration for distributed locks (thanks to pieceofsummer)
- Add epired jobs watch to cleanup succeeded/deleted lists (thanks to pieceofsummer)
- Make succeeded and deleted lists size configurable (thanks to pieceofsummer)
- Fix job state order (thanks to pieceofsummer)
- Exclude Fetched property from job parameters (thanks to pieceofsummer)
1.7.1
- Add expired jobs watcher to cleanup succeeded/deleted lists thanks to pieceofsummer
1.7.0
- Redis Cluster support (#42 thanks to gzpbx)
- Update to VS2017 (#48 thanks to ryanelian)