Lucee Tag Reference

<cfdistributedlock>

Redis based lock that can be used across servers

Body

This tag must have a body.

Example

<cfdistributedlock
	[amount=numeric]
	[bypass=boolean]
	cache=string
	[expires=numeric]
	[logontimeout=boolean]
	name=string
	[throwontimeout=boolean]
	[timeout=numeric]>
</cfdistributedlock>
This tag is also supported within cfscript
<cfscript>
	distributedlock
		[amount=numeric]
		[bypass=boolean]
		cache=string
		[expires=numeric]
		[logontimeout=boolean]
		name=string
		[throwontimeout=boolean]
		[timeout=numeric] {
			[...]
	}
</cfscript>

Attributes

The attributes for this tag are fixed. Except for the following attributes no other attributes are allowed.
Name Type Required Description
amount numeric No Defines the amount of parallel threads allowed within the lock, default is 1. 
bypass boolean No If set to true the lock is not done at all. 
cache string Yes name of the redis cache used to lock. 
expires numeric No The time in seconds a lock remains in case it not get released, by default this is 10 minutes. 
logontimeout boolean No In case we reach a timeout, and the value is set to yes, we log this to the application.log. Default is Yes. 
name string Yes Specifies the name of the lock.
Only {amount} (see attribute amount) request(s) can execute inside this tag with a given name.
Therefore, providing the name attribute allows for synchronizing access
to resources from different parts of an application.
Lock names are global to a server.
They are shared between applications and user sessions,
but not across clustered servers. 
throwontimeout boolean No Yes or No. Specifies how timeout conditions are handled.
If the value is Yes, an exception is generated to provide notification of the timeout.
If the value is No, execution continues past the cfclock tag. Default is No. 
timeout numeric No Specifies the maximum amount of time in seconds, to wait to obtain a lock.
If a lock can be obtained within the specified period, execution continues inside the body of the tag.
Otherwise, the behavior depends on the value of the throwOnTimeout attribute.
The value must be at least 0.01.