> Over the years, I've rarely used cflock for anything. I > still don't fully understand when I should use it. > > Anyway, I'm concerned about scaling CFMBB... lots of > application scoped stuff. > > For example, there are many places where I do this: > > <cfset application.forum.updateForumData()> > > Application.forum is an instance of forum.cfc ... all the > updateForumData() does is run a bunch of queries to make sure > the denormalized columns in the forums table (msgcount and > lastpost) and in the threads table (lastpost) are up to date. > This method is called each time a message or topic is posted > or deleted, and each time a forum or conference is created or deleted. > > And everywhere I run it, I do this immediately after: > > <cfset application.qryForums = application.forum.getForums()> > <cfset application.qryThreads = > application.thread.getThreads()> > > This seems like a place where I might need locking ... but > I'm really not sure =) > > In a very busy environment, this code could run a lot... > imagine thousands of active users on a baseball team web site > during the world series.. all posting new resposnes to the > "official game thread"... > where you might get 2000 responses or more during a 3 hour game. > > And yet your list of threads might get viewed 100 times per > second during that time (which is why I'm putting the data - > a relatively small amount of data.. just list of forums and > list of threads) into the application scope.
The answer is, it depends! As James and Brian point out, this is a race condition. The question you need to ask, though, is does this race condition matter? If two requests run this code at nearly the same time, can the second request cause a logical error in the first request? Many race conditions can be safely ignored, since they don't cause logical errors that have any significance. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| ColdFusion 8 - Build next generation apps today, with easy PDF and Ajax features - download now http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:286915 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

