-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
> According to Allaire documentation, all reads/writes to application
> variables should be protected with a lock. Does this mean
> that I only really
> need to lock variables that I set in the application.cfm -OR-
> does it mean
> that I really need to lock every instance in the entire
> application?
Let me make this abundantly clear, as a service to the CF community
in general.
IT IS AN ABSOLUTE NECESITY THAT YOU LOCK ALL SESSION, APPLICATION,
AND SERVER VARIABLES WHEN YOU WRITE OR READ THEM. In fact, you
should probably have a CFLOCK in your brain when you even THINK about
them.....
Now... If you're using 4.5.1 and you choose automatic read locking,
then you can read variables in those scopes without locking them, but
you MUST still lock them to write to them. You do pay a small
performance hit for this convenience, however. If you're NOT an ISP
or some other unfortunate soul who has to run other people's code on
your servers, then for maximum performance you should set your
servers for no lock checking. Then you need to make 150% certain
that you're locking everything as you should. If you're NOT locking
variables, and you DON'T have the server configured to check for
locking, then it's just a question of 'WHEN', not 'IF' multiple users
will hit the same variables at once & cause you hell. It WILL bring
down your server if that happens repeatedly.
It doesn't matter whether your variables are in app.cfm or elsewhere.
You ALWAYS need to lock them.
> <cfoutput>
> Thank you for visiting the
> <cflock ...>#application.applicationName#</cflock>
> sponsored by
> <cflock ...>#application.companyName#</cflock>
> </cfoutput>
That's one way to do it. Another would be to do:
<Cflock type="readonly" scope="application" timout="5">
<!--- One fewer lock opened & closed, so less overhead --->
<!--- Also makes for a nicer looking CFOUTPUT block --->
<cfset applicationName = application.applicationName>
<Cfset companyName = application.companyName>
</cflock>
<cfoutput>Thank you for visiting the #applicationName# sponsored by
#companyName#</cfoutput>
> <cflock ...>
> <cfif application.appOpen>
> <A href="here.cfm">Click Here</a> to begin
> </cfif>
> </cflock>
That block of code will bite you in the rump at some point...
> if it is the latter, what happens when the variable is
> include another tag,
> such as CFIF or CFQUERY? don't you have to lock the entire tag,
> i.e.: <cflock ...>
> <cfquery datasource="#application.dataSource#">
> SELECT... FROM... WHERE...
> </cfquery>
> </cflock>
Like above, set a local variable & use that instead. Thusly:
<cflock type="readonly" scope="application" timout="5">
<!--- Assuming you do more than one query in this page for the same
datasource, this should run faster since accesses to local vars are
supposed to be quicker than accesses to application scope variables.
- --->
<Cfset DSN = Application.Datasource>
</cflock>
<Cfquery datasource="#DSN#">
SELECT... FROM... WHERE...
</cfquery>
It's certainly very possible to have a site that will run for weeks
without proper locking, provided the load is low. Every time that
two different user sessions try to write to a session, application,
or server variable at the same time, the CFAS process degrades just a
little bit. If you get enough of those collisions happening over
time, your server WILL come down. It's really not such a big deal to
lock variables, nor is it much of a performance hit, provided your
site is well designed. Since you can specify readonly locks, 90% of
the time the CFLOCKS will have no real effect on concurrent accesses
to the same page. The only time it becomes an issue is when you need
to write variables.
Best regards,
Zac Bedell
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.3 for non-commercial use <http://www.pgp.com>
Comment: Please use PGP!!!
iQA/AwUBOYB4dgraVoMWBwRBEQIXbQCcCLWBkN9VZeR6+kDyafi1STJa09IAoKM+
Ot5KWuFZiR1TrVxPbC6HTBpl
=9rU/
-----END PGP SIGNATURE-----
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.