Best practices says you should lock all shared scope access, reads and
writes. Reads can be locked using a readonly lock, while writes need an
exclusive lock. See Using Persistent Data and Locking in Developing
ColdFusion MX Applications in the CFMX Docs for best practices.

Personally, I don't even bother with cflock on shared scope reads on small
sites. The last time I did a test of session read integrity it took a VERY
high number of simultaneous reads to generate an error. Something on the
order of 100K reads in a cloop in a page called simultaneously in 10 frames
in a browser. That was on a 1 GHz development server against CF 5.0. Shared
scope writes failed at 10K writes in a loop in the same page. You can easily
conduct this test yourself if you are curious about where the breaking point
for shared scopes is.

As an alternative, you can always do something like copy the session scope
into a different scope (like the request scope) in your application.cfm,
then copy the request scope back into the session scope in onrequestend.cfm.
That frees you from writing locks everywhere, which is just a pain, but you
wil incur extra overhead with this method.

>
>Should I also be wrapping ALL my <cfif> statements with <cflock>?
>
>
>What about the below?
>
> <cflock timeout="10" type="READONLY" scope="SESSION">
> <CFX_Users ACTION="" USER="#SESSION.auth#"
>PASSWORD="#FORM.OldPassword#">
> </cflock>
>
>I'm using alot of <cfloop>. Should I be wrapping all these with <cflock>
>also>
>
> <cflock timeout="10" type="EXCLUSIVE" scope="SESSION">
> <cfloop index=List list="#SESSION.name#">
>...</cfloop>
></cflock>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to