This all depends on what the "some code here..." does. Let's be clear on what people mean when they say cflock is less important now. cflock is no longer required to ensure that memory does not get corrupted and variables aren't read at the same time they are being written.
That being said, there are very good reasons to use cflock. So back your "some code here..." code-- Does it require that the arrayLen be the same at the time the if statement was run? If the code in the if statement will error if the length of session.customer.custerrors is zero, then you need to go with your first option to make sure no one changes that variable while you are in the cfif since your if statement was entered under the assumption that the array had length. *IMPORTANT* This will ONLY work if you _also_ wrap every place that modified the session.customer.custerrors variable with an exclusive lock. And on that note, I would use a named lock, not a session-wide lock since it is a shame to lock the entire scope if you really only care about one variable. I generally name the lock after the variable I am accessing. And, is there a reason you didn't want to throw an error on lock timeout? If the application requires the code in the if statement to run, code farther down the page might be borked if you just silently let the cflock get skipped. <cflock timeout="20" throwontimeout="Yes" type="READONLY" name="session.customer.custerrors"> <cfif arrayLen(session.customer.custerrors)> <cfset session.customer.custerrors[1] = 'foo'><!--- this line would error if the array was emptied before we reached it ---> </cfif> </cflock> ~Brad -------- Original Message -------- Subject: Quick question on cflock... From: "Che Vilnonis" <[email protected]> Date: Wed, September 09, 2009 12:54 pm To: cf-talk <[email protected]> What is the best pratice when in comes to using cflock looking at the code snippets below? Basically does a session-based <cfif> block need to be nested within a cflock or not? I'm pretty sure it does. Thanks, Che ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326162 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

