MemoryStorage available for testing


I’ve discovered hang fire few month ago. I’ve wanted to check how hangfire works but I do not want to install/deploy an SQL Server or something else. The overview and dashboard screenshots are really good. I was sad to do not quickly see it, again and again with 1.3, 1.4 and now 1.42 version !
So, I’ve read how SQL Server, MongDB and others storage was implemented. And even if it is not easy than creating a job, it’s not a big deal.

I’ve tried to create a quick and easy storage which contains everything in memory.
After some tests, it seems to work with any job and the dashboard.

Source code is available here:

Only need to compile, add reference and this single line of code:

Hope it can help. Feel free to check and comment.


Hey that’s neat! Really useful for testing stuff; thanks.


I’ve updated the repository with 1.4.3 version, if needed (nothing has changed).

great for quick testing

Thank you. Very nice project!
Could you please add it to


Thank you, you’ve right. It’s easier with a Nuget package.

It’s done : PM> Install-Package Hangfire.MemoryStorage

1 Like

Looking to use MemoryStorage as BackgroundJob.Enqueue was persisting a a new job each time the app starts and I need the job to go away on app shutdown. Resorting to this as I did not see a way to purge old job.

Additionally there are two MemoryStorageOptions for which I find no documentation. If you could please point me to any documentation on these options CountersAggregateInterval and JobExpirationCheckInterval.


Sir, I honestly should pay you for that, I was struggling with an unit test to pass for half a day and this solution solved it in a second. I owe you

Glad to hear that it was helpful to you.

Hangfire Memory component can be used for production or it is only use for testing?

It was not designed/tested for production but it should work.
But for production, I think that a persistent storage seems to be a better solution.

Hey @perrich, listen I’ve found a bug maybe? I was using hangfire with sqllite and when switched to your storage i got some unit test failing because the job history list was sorted the other way arround. I dont know if its sql lite storage or yours the prob.

I’ve fixed it with this:
_stateHistoryDto = jobDetailsDto.History.OrderByDescending(x => x.CreatedAt).First();

the old code had no sorting after the history property


From your comments you was using hangfire with SqlLite. I would like to know which extension you are using for this SqlLite integration.

Kindly provide your answers for this question