Understanding Locking


The concept of locking is well established in multi-user environments. File locking prevents multiple users from editing a file at the same time. Database management systems also use locking by allowing different users to access the same records without interference. In a ColdFusion environment, locking is used to explicitly manage the sequence in which concurrent requests are processed.

There are generally two reasons to use locks within ColdFusion:

  • To prevent simultaneous access to codefor example, if you were writing a file with <cffile>, you wouldn't want another process reading that same file while it was being written.

  • To ensure that a block of code is executed as a groupfor example, if you were updating ten APPLICATION variables, you wouldn't want other requests to read five old variables and five new ones (you'd want other requests to pause until all ten were written).

NOTE

As of ColdFusion MX, opting not to lock access to shared scopes (SESSION, APPLICATION, and SERVER) will not cause memory corruption.




Macromedia ColdFusion MX 7 Certified Developer Study Guide
Macromedia ColdFusion MX 7 Certified Developer Study Guide
ISBN: 0321330110
EAN: 2147483647
Year: 2004
Pages: 389
Authors: Ben Forta

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net