The following example shows how to use a cflock block to synchronize access to a file system. The cflock tag protects a cffile tag from attempting to append data to a file already open for writing by the same tag executing on another request.
If an append operation takes more than 30 seconds, a request waiting to obtain an exclusive lock to this code might time out. Also, this example uses a dynamic value for the name attribute so that a different lock controls access to each file. As a result, locking access to one file does not delay access to any other file.
<cflock name=#filename# timeout=30 type="Exclusive"> <cffile action="Append" file=#fileName# output=#textToAppend#> </cflock>