Overview
Tries to acquire a lock for the enclosure key until the lock is retrieved.string $Cache.Lock(key: string)
string $Cache.Lock(key: string, blockingTimeout: string)
Arguments
Remarks
This method automatically enters to wait state for shared key is set to free until timeout is reached. If you do not want to wait please use the$Cache.TryLockmethod instead.
Acquired lock always must be released with$Cache.ReleaseLockmethod with generated token value. Otherwise lock is kept for long period until it's expire. (Default 5 min)
Example
$Cache.Set('myint', 4); var tokenValue = $Cache.Lock('myint'); // Locked code block $Cache.ReleaseLock('myint',tokenValue);
Remarks
This method automatically enters to wait state for shared key is set to free until timeout is reached. If you do not want to wait please use the$Cache.TryLockmethod instead.
Acquired lock always must be released with$Cache.ReleaseLockmethod with generated token value. Otherwise lock is kept for long period until it's expire. (Default 5 min)
Example
$Cache.Set('myint', 4); var tokenValue = $Cache.Lock('myint'); // Locked code block $Cache.ReleaseLock('myint',tokenValue);
Examples
$Cache.Set('myint', 4); var tokenValue = $Cache.Lock('myint'); // Locked code block $Cache.ReleaseLock('myint',tokenValue);