Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

Overview

Tries to acquire lock for a shared key.

string $Cache.TryLock(key: string)

Arguments

string key
Shared lock key.

Returns

Token value in string if lock has acquired, otherwise null.

Remarks

This method immediately checks to shared key is locked and generates token if shared key is not locked. Does not perform any wait operation for availability, if you want to wait for short period, please use the Lock method instead.

Example

$Cache.Set('myint', 4);
var tokenValue = $Cache.TryLock('myint');
if (tokenValue != null) {
  // Locked code block 
  $Cache.ReleaseLock('myint',tokenValue1);
} else {
  // Already locked  
}
  • No labels