So, I am working on a legacy application written in .NET 2.0 and C# that's only purpose is to execute workflows (background jobs or processes). In essence what it does is:
- On app startup it loads all objects from DB into memory (in classes called Holder)
- Start the processes (multiple of them) each in its own thread
- These processes works on the data in memory (multi-threaded) so the data access is kept between locks.
So the above picture depicts the process to work with the data.
I have the task to modernize this using new .NET 7 + Entity Framework and its capabilities. Because this application is heavily multi-threaded and many of the infrastructure classes like (workers, holders, dal access) are singletons there is locking everywhere.
My wishes are this:
- Because of multiple threads accessing the same data, I would like to get rid of those singletons. But the problem for me is where should I keep the in memory data the workflow needs to work with it.?
- If I choose to not remove singletons, then I was thinking to use Repository pattern to hold the entities in memory, but then I they should be singletons any I don't know if this is a good idea.
So my problem is where to keep the data once is loaded so that many threads can use (read, update delete) it without going into DB each time?
I need a design pattern for this, or maybe use some sort of Level2 cache for Entity Framework
Aucun commentaire:
Enregistrer un commentaire