Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Duration of waiting timeout in hh:mm:ss format. Default value is 60 second.

Returns

...

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.TryLock method instead.

Acquired lock always must be released with $Cache.ReleaseLock method with generated token value. Otherwise lock is kept for long period until it's expire. (Default 5 min)

Example

Try to wait for a lock for a shared key and release it after operation is completed.

Code Block
languagejs
$Cache.Set('myint', 4);
var tokenValue = $Cache.Lock('myintmylock');
try {
  // Locked code block
}
finally{
  $Cache.ReleaseLock('myintmylock',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

Code Block
languagejs
$Cache.Set('myint', 4);// Wait for 30 seconds if already locked
var tokenValue = $Cache.Lock('myint'mylock', '00:00:30');
try {
  // Locked code block    
}
finally {
  $Cache.ReleaseLock('myintmylock',tokenValue);

Examples

Code Block
languagejs
$Cache.Set('myint', 4); var tokenValue =
$Cache.Lock('myint');
// Locked code block
$Cache.ReleaseLock('myint',tokenValue);}

See Also