I have a class as shown below with a static object used for caching some values to avoid going to the DB all the time for it.
When the DoWork method is enqueued and the job is executed by hangfire, is the object loaded once or multiple times?
public class SomeClass
{
private static SomeData myCache = LoadValuesFromDb();
private static SomeData LoadValuesFromDb()
{
//Reads some values from DB
}
public void DoWork(int id)
{
//Uses myCache to do some work.
}
}
for(int i = 0; i < 10; i++)
{
BackgroundJob.Enqueue<SomeClass>(x => x.DoWork(i));
}