RE: good old CFLOCK question
In my CF4 and CF5 days I found that it was actually faster to lock an entire scope (application) then set multiple variables in that scope before releasing the lock. I'd do something like: if(not isDefined("Application.datasource")) Application.datasource = "mydatasource"; if(not isDefined("Application.adminname")) Application.adminname = "Steve!"; ... This ran MUCH faster than doing each one individually. I've just kept in that habit since then, but I don't think there is a speed difference with MX or MX7. Thanks, Steve -Original Message- From: James Holmes [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 10, 2006 8:33 AM To: CF-Talk Subject: Re: good old CFLOCK question I'm inclined to agree - use named locks. On 1/10/06, Baz <[EMAIL PROTECTED]> wrote: > I know locking questions have come up before... but it's a quickie... > > Is there ever a reason to lock an entire scope instead of using named locks? > It seems that locking an entire scope just causes extreme inefficiency > without any advantages... -- CFAJAX docs and other useful articles: http://jr-holmes.coldfusionjournal.com/ ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:229015 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: good old CFLOCK question
An application scoped lock works just for that application. A session scoped lock works just for that user's session. It's all a matter of how an app is structured. Take 10 threads that need to write to different data in the application scope for an app; named locks let them all operate at once, while a scoped lock single-threads the app. On 1/10/06, Robert Everland III <[EMAIL PROTECTED]> wrote: > I would think that named locks would end up being difficult to manage. You > would have to remember that you locked session.variablename with the lock > lockname. My question would be is does locking lock the scope for the whole > box, or only for that application and that scope. -- CFAJAX docs and other useful articles: http://jr-holmes.coldfusionjournal.com/ ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:229014 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
RE: good old CFLOCK question
Baz, Think this through locking the "session" scope locks "THIS" session, so you are really keeping the user from interfering with himself. In a sense, using named locks for session scope may be overkill unless you have some kind of polling or long running scripts, or perhaps you are setting or updating the same variable constantly - in that case a named locke would be a good choice I think. Locking the Application scope does indeed lock it "for everyone", but the Application scope is usually used in a "write once read many" fashion. I do not typically lock reads anymore for that scope - just writes so if I'm writing to the scope once (with a scope lock) and then reading from it, there's no real penalty there that I can see. In addition, the "Application.cfc" approach negates the need to add specific locks because I can now use the "onApplicationStart( )" script to set up my variables. The Exception in the case of the application variable is a "counter" or "tracking" variable that is updated regularly - tracking logged in users for example. In that case a named lock would keep you from locking the entire scope and make perfect sense. That's my take. -Mark -Original Message- From: Baz [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 10, 2006 7:21 AM To: CF-Talk Subject: good old CFLOCK question I know locking questions have come up before... but it's a quickie... Is there ever a reason to lock an entire scope instead of using named locks? It seems that locking an entire scope just causes extreme inefficiency without any advantages... Thanks, Baz ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:229013 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: good old CFLOCK question
I would think that named locks would end up being difficult to manage. You would have to remember that you locked session.variablename with the lock lockname. My question would be is does locking lock the scope for the whole box, or only for that application and that scope. Bob ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:229009 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: good old CFLOCK question
I'm inclined to agree - use named locks. On 1/10/06, Baz <[EMAIL PROTECTED]> wrote: > I know locking questions have come up before... but it's a quickie... > > Is there ever a reason to lock an entire scope instead of using named locks? > It seems that locking an entire scope just causes extreme inefficiency > without any advantages... -- CFAJAX docs and other useful articles: http://jr-holmes.coldfusionjournal.com/ ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:229008 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
good old CFLOCK question
I know locking questions have come up before... but it's a quickie... Is there ever a reason to lock an entire scope instead of using named locks? It seems that locking an entire scope just causes extreme inefficiency without any advantages... Thanks, Baz ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:229005 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54