After developing a evidence of concept to have an ASP.Internet MVC site and ensuring the right separation of concerns were in position, I observed which i was making lots of costly redundant database requires details about the present user.
Being in the past a desktop and services person, my first thought ended up being to cache the db leads to some
statics. It did not take much searching to determine that carrying this out would persist the present user's data over the whole AppDomain for those customers.
Next I figured of utilizing
HttpContext.Current. However, should you put stuff here whenever a user is drenched out, when they sign in your cached data is going to be outdated. I possibly could update this each time login/logout happens however i can't know if this feels right. Even without the other ideas, this is when I am leaning.
Exactly what is a lightweight method to precisely cache user particulars and steer clear of needing to make a lot of database calls?
When the information you need to cache is per-user and just while they're active, then Session is the best place.
What you are searching for is System.Web.Caching.Cache
ASP.Internet session-condition management will work for some situations however when heavy load is defined, it has a tendency to create bottlenecks in ASP.Internet performance. Find out more about this here:
The reply to avoid bottlenecks is utilization of distributed caching. You will find many free distributed caching solutions on the market like Memcached or NCache Express.
Have no idea much about Memcached but i have used NCache Express by Alachisoft, it allows you utilize ASP.Internet caching without needing any code change.