LockAsync¶
Asynchronously attempts to acquire a lock without blocking the script execution thread while waiting.
1 | |
Parameters¶
string key
The lock key, which is a unique identifier for shared access.
string blockingTimeout optional
The maximum duration to wait in "hh:mm:ss" format. The default is 60 seconds.
string duration optional
The lock lifetime in "hh:mm:ss" format.
string tryLockInterval optional
The interval between acquisition attempts in "hh:mm:ss" format.
Returns¶
A promise containing the acquired token, or null when the timeout expires.
Remarks¶
Prefer this method over $Cache.Lock in asynchronous scripts.
Waiting asynchronously for up to 30 seconds and always releasing the acquired lock¶
1 2 3 4 5 6 7 8 9 10 11 | |
Configuring the wait time, lock lifetime, and interval between acquisition attempts¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |