I've searched a lot of posts and I have not been able to find a question which addressed my exact specific requirements. Here's what I'm trying to achieve:
Background:
I have a ASP.NET core MVC application. I'm trying to minimize the database trips by reusing the data which are not being changed regularly. I have 2 groups of data which I call Statics and Dynamics
Statics: They never change for the entire application life. (Entity types, Status names, etc)
Dynamics: They are specific for each login. (Business details, list of services, tax details etc. These will be different for each logged in user)
For the Statics, upon application start, I go to the database and store these values in the static fields of a static class. From this point forward everyone have this data without a single trip to the database. So far so good. Statics are being used in all layers; presentation, business, persistence. This saves me tons ot database trips.
My Problme
I want the following behavior for the Dynamics Each time a user logs in, a data container (similar to Statics) is populated for that user only. So for as long as that user is logged in, she doesn't need to go to the database for her needs of anything in the Dynamics
When another user logs in, he gets his own set of Dynamic data container that he can use from anywhere in the application. From all the layers.
How can I achieve this functionality?
The Statics is a class in the Business layer and has it's own data manager which is being called upon application start up.
I need to have a similar setup for Dynamics with its own data manager which is being called upon each user log in to populate the Dynamics and reuse the data for the duration of log in.
Naturally I cannot use a static class and static fields because they will be overridden by each log in and all the other users get the incorrect data.
Many thanks in advance