MemoryStorage available for testing

memory-storage
Tags: #<Tag:0x00007fa53bed3518>

#1

Hi,

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: https://github.com/perrich/Hangfire.MemoryStorage

Only need to compile, add reference and this single line of code:
GlobalConfiguration.Configuration.UseMemoryStorage();

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

Florian


#2

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


#3

Thanks.

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


#4

great for quick testing


#5

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


#6

Hi,

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

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


#7

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.

Thanks


#8

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


#9

Glad to hear that it was helpful to you.


#10

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


#11

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.