Queue access to the database to avoid multiple cache items
- by MikeJ
I have a music related ASP.NET web site which caches a lot of static information from the database on the first request.
Sometimes, the application is reset and cache is cleared while the application is on heavy load and then all http requests go to the database to retrieve that static data and cache it for other requests.
How can I ensure that only one request go to the database and cache the results, so that other request simply read that info from cache and not needlessly retrieve the same info over and over again.
Can I use thread locking? For example, can I do something like lock(this) { db access here }?