Zac,
Thanks. This was very helpful.
One clarification question. Does a Named lock prevent a same-named thread
within the session or application(on a single server?)?
Andy
----- Original Message -----
From: "Zachary Bedell" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Thursday, February 22, 2001 10:01 AM
Subject: RE: How to choose Name or Scope when locking
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> > I haven't seen anything yet that talks explicitly about when
> > to use the Name attribute and when to use the Scope
> > attribute. There have been a number of threads around
> > whether to single thread updates to a single table.
> >
> > For example, lets say that I read from a table in two
> > programs and write/delete from a third. For this example,
> > lets say I want to single thread all writes. To do this,
> > would you use scope="application" type="readonly" to lock
> > the two read queries and scope="application" type="exclusive"
> > around the write or would replace the scope attribute in both
> > with something like name="databasename.tablename"?
>
> First of all... Why in lord's name would you want to single thread
> your DB access? You use an RDBMS like Access, SQL Server, or
> whatever because your DB handles all the locking & concurrency issues
> for you. I can think of a few VERY limited cases where you might
> need to single thread access (perhaps in some sort of status tracking
> or *something*). If I ever ran into a situation like that, I'd think
> LONG & HARD about how to get around the problem without single
> threading the DB. That's just ASKING for performance nightmares...
>
> In any case, if you did need to lock your DB for one particular
> table, then you would use a named lock with something like
> name="database.table" or whatever.
>
> Here's the skinny on when to use scope & when to use name for CFLOCK:
>
> If you're accessing a shared CF variable in the session, application,
> or server scope, then you should use a scoped lock of the appropriate
> scope. You *shouldn't* access more than one scope within a single
> lock, tho I suspect you could access session in an application lock
> and application & session in a server lock without killing the
> server. I would think that if automatic checking is enabled, it
> would probably disallow that activity. I certainly wouldn't code
> anything to use it.
>
> For basically everything else, you use named locks. When you're
> controlling access to anything that falls outside of the three CF
> shared scopes -- mostly "outside world" type of stuff -- scope
> doesn't work.
>
> Examples:
> You have a non-thread safe CFX tag. You should use a lock that is
> the name of the tag around all accesses to it.
> Your DB example above is another valid example, tho I'm not sure why
> you'd want to do that.
>
>
> Hopefully that's at least a little clearer than mud...
>
> Best regards,
> Zac Bedell
>
> -----BEGIN PGP SIGNATURE-----
> Version: PGPfreeware 6.5.8 for non-commercial use <http://www.pgp.com>
> Comment: Please use PGP!
>
> iQA/AwUBOpU3x6vhLS1aWPxeEQJrsgCfR5nOE8vtxMj+PZLLim4GUIPI/mYAn2Hk
> iacc+HOazuS3mA+jxE63BbXa
> =E//I
> -----END PGP SIGNATURE-----
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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