Queue access to the database to avoid multiple cache items
Posted
by MikeJ
on Stack Overflow
See other posts from Stack Overflow
or by MikeJ
Published on 2010-06-07T12:39:24Z
Indexed on
2010/06/07
12:42 UTC
Read the original article
Hit count: 233
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 }?
© Stack Overflow or respective owner