RE: Locking question?
No locking is needed for the REQUEST scope. -Original Message- From: Tilbrook, Peter [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 22, 2003 6:09 PM To: CF-Talk Subject: Locking question? Do I need to LOCK variables (when setting or reading)variables in the REQUEST scope - particularly in the application.cfm? My thoughts are no I don't but I wanted to check. Cheers! == Peter Tilbrook Internet Applications Developer Australian Building Codes Board GPO Box 9839 CANBERRA ACT 2601 AUSTRALIA WWW: http://www.abcb.gov.au/ E-Mail: [EMAIL PROTECTED] Telephone: (02) 6213 6731 Mobile: 0439 401 823 Facsimile: (02) 6213 7287 ** The information contained in this e-mail, and any attachments to it, is intended for the use of addressee and is confidential. If you are not the intended recipient, you must not use, disclose, read, forward, copy or retain any of the information. If you have received this e-mail in error, please delete it and notify the sender by return e-mail or telephone. The Commonwealth does not warrant that any attachments are free from viruses or any other defects. You assume all liability for any loss, damage, or other consequences which may arise from opening or using the attachments. ** ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Get the mailserver that powers this list at http://www.coolfusion.com Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Locking question?
Nope. Just Session, Server and Application scopes. -Original Message- From: Tilbrook, Peter [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 22, 2003 6:09 PM To: CF-Talk Subject: Locking question? Do I need to LOCK variables (when setting or reading)variables in the REQUEST scope - particularly in the application.cfm? My thoughts are no I don't but I wanted to check. Cheers! == Peter Tilbrook Internet Applications Developer Australian Building Codes Board GPO Box 9839 CANBERRA ACT 2601 AUSTRALIA WWW: http://www.abcb.gov.au/ E-Mail: [EMAIL PROTECTED] Telephone: (02) 6213 6731 Mobile: 0439 401 823 Facsimile: (02) 6213 7287 ** The information contained in this e-mail, and any attachments to it, is intended for the use of addressee and is confidential. If you are not the intended recipient, you must not use, disclose, read, forward, copy or retain any of the information. If you have received this e-mail in error, please delete it and notify the sender by return e-mail or telephone. The Commonwealth does not warrant that any attachments are free from viruses or any other defects. You assume all liability for any loss, damage, or other consequences which may arise from opening or using the attachments. ** ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: locking question
You can lock them all as a group. Cheers, Jeff Garza Webmaster, Spectrum Astro, Inc. [EMAIL PROTECTED] -Original Message- From: Alii Design To: CF-Talk Sent: 6/2/01 8:18 AM Subject: locking question Do you need to lock each session variable individually or can you lock them all as a group using a cfscript? Rich ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Locking Question
The scope attribute was added in ColdFusion 4.5. In ColdFusion 4, you can approximate this behavior by using the name attribute. For Session variables, use the name #Session.SessionID#. For Application variables, use the name #Application.ApplicationName#. Benjamin S. Rogers Web Developer, c4.net Voice: (508) 240-0051 Fax: (508) 240-0057 -Original Message- From: David Baskin [mailto:[EMAIL PROTECTED]] Sent: Monday, May 14, 2001 5:10 PM To: CF-Talk Subject: Locking Question Hello, i'm setting a session variable in a template so i'm using cflock, but i'm getting an error on the scope attribute. i've checked the documentation and it doesn't list scope as valid, but it shows up in Studio and well, it just makes sense that you would use scope. Below is the code i was trying to use. Also, what is the proper timeout that should be used for locking session variables. Thanks for any help. d !--- session setup --- cflock scope=SESSION timeout=2 throwontimeout=Yes cftry cfset session.userID = FORM.userID cfcatch type=Lock cflocation url=index.cfm?error=2 /cfcatch /cftry /cflock !--- end session setup --- cfinclude template=whatever.cfm ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: Locking question
Jon Hall wrote: I have seen all of the warnings to make sure to use cflock around any of the in memory variable types in a CF application. I hear that every access of a session, or application variable should have cflock around it, or I could enable automatic locking on the server which will exact a performance hit though. Is there a different kind of lock I should use when reading a session or app variable than when I am writing to one of these variables? As long as you are using cf 4.5, make sure you use the scope attribute of a CFLOCK. CFLOCK scope="session"(for session variables) CFLOCK scope="application" (for application variables) How about when I create a session or app variable? You want to use the type attribute of CFLOCK. CFLOCK type="exclusive" (for reading) CFLOCK type="read-only" (for writing) At this point, I hope I haven't swapped the use of type and the use of scope, so check your documentation. ;) Here is a bit of code from a shoppingcart that I have written. It's is the addtocart()... Where should the cflocks go? Since I am not totally sure about cflock and it's uses I currently just cflock all of this tag, essentially single threading the entire function. This probably isn't too bad, since performance isn't a big requirement for the sites that I am using this code on. In my never ending quest for that extra millisecond though, understanding cflock is the next step. cfif isDefined("attributes.price") and isDefined("attributes.quantity") and isDefined("attributes.itemcode") cfif NOT isDefined("session.cart") cfset session.cart = structnew() /cfif You'll want to use an exclusive lock here. cfset temp = ListToArray('#attributes.price#,#attributes.quantity#') cfif NOT structKeyExists(session.cart, attributes.itemcode) cfset rs = structInsert(session.cart, attributes.itemcode, temp) cfelse cfset temp[2] = attributes.quantity cfset rs = structUpdate(session.cart, attributes.itemcode, temp) /cfif You'll want to put a lock around the above if statement, also exclusive. /cfif Why not remove all session variable access from your 'function'? Create a temporary variable for your cart and pass it back into the caller (if this is a custom tag). You eliminate the need for CFLOCKs within your function. After the function is complete, just add a line (surrounded by CFLOCK) CFSET session.cart = mytempcart Food for thought. -- Jeff Houser | mailto:[EMAIL PROTECTED] AIM: Reboog711 | ICQ: 5246969 | Phone: 860-229-2781 -- Instant ColdFusion 4.5 | ISBN: 0-07-213238-8 Due out 3rd Quarter 2001 -- DotComIt, LLC database driven web data using ColdFusion, Lotus Notes/Domino -- Half of the Alternative Folk Duo called Far Cry Fly http://www.farcryfly.com | http://www.mp3.com/FarCryFly -- I've got the brains, you've got the looks, let's make lots of money ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Locking question
In short 1) You need to have locks around even the Cfif Isdefined() statements. In order for CF to check if a function is defined it has to attempt a read of said function. 2) When accessing a shared variable to read its value the cflock type="" attribute should be Readonly. 3) When accessing a shared variable to create or modify its value the cflock type="" attribute should be Exclusive. I would modify your code like this: cfif isDefined("attributes.price") and isDefined("attributes.quantity") and isDefined("attributes.itemcode") cflock timeout="1" throwontimeout="No" type="EXCLUSIVE" scope="SESSION" cfif NOT isDefined("session.cart") cfset session.cart = structnew() /cfif /cflock cfset temp = ListToArray('#attributes.price#,#attributes.quantity#') cflock timeout="1" throwontimeout="No" type="EXCLUSIVE" scope="SESSION" cfif NOT structKeyExists(session.cart, attributes.itemcode) cfset rs = structInsert(session.cart, attributes.itemcode, temp) cfelse cfset temp[2] = attributes.quantity cfset rs = structUpdate(session.cart, attributes.itemcode, temp) /cfif /cfif /cflock /cfif I used exclusive locks because after the isdefined(), which by itself only requires a readonly lock, you're modifying the session variables. |-Original Message- |From: Jon Hall [mailto:[EMAIL PROTECTED]] |Sent: Saturday, February 17, 2001 5:11 PM |To: CF-Talk |Subject: Locking question | | |I have seen all of the warnings to make sure to use cflock |around any of |the in memory variable types in a CF application. I hear that |every access |of a session, or application variable should have cflock |around it, or I |could enable automatic locking on the server which will exact |a performance |hit though. Is there a different kind of lock I should use |when reading a |session or app variable than when I am writing to one of these |variables? |How about when I create a session or app variable? | |Here is a bit of code from a shoppingcart that I have written. |It's is the |addtocart()... Where should the cflocks go? Since I am not totally sure |about cflock and it's uses I currently just cflock all of this tag, |essentially single threading the entire function. This |probably isn't too |bad, since performance isn't a big requirement for the sites |that I am using |this code on. In my never ending quest for that extra |millisecond though, |understanding cflock is the next step. | |cfif isDefined("attributes.price") and |isDefined("attributes.quantity") |and isDefined("attributes.itemcode") | |cfif NOT isDefined("session.cart") | cfset session.cart = structnew() |/cfif | |cfset temp = ListToArray('#attributes.price#,#attributes.quantity#') | |cfif NOT structKeyExists(session.cart, attributes.itemcode) | cfset rs = structInsert(session.cart, attributes.itemcode, temp) |cfelse | | cfset temp[2] = attributes.quantity | cfset rs = structUpdate(session.cart, attributes.itemcode, temp) |/cfif | |/cfif | |jon | | | ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists