CSLockUtils
in package
This utility class provides lock utilities.
Tags
Table of Contents
- acquireLockForName() : bool
- Acquires a lock with the specified name. This lock gets automatically release when the request ends (finishes or aborts)
- acquireLockForRecord() : bool
- Acquires a lock for a record. This lock gets automatically released when the request ends (finishes or aborts)
- canAcquireLockForName() : bool
- Checks if a lock with the specified name can be acquired. If the lock should also be acquired, please use "acquireLockForName" directly, as this requires only 1 query, instead of 2.
- canAcquireLockForRecord() : bool
- Checks if a lock for a record can be acquired. If the lock should also be acquired, please use "acquireLockForRecord" directly, as this requires only 1 query, instead of 2.
- releaseLockForName() : bool
- Releases a lock previously acquired with acquireLockForName.
- releaseLockForRecord() : bool
- Releases a lock for a record previously acquired with acquireLockForRecord.
Methods
acquireLockForName()
Acquires a lock with the specified name. This lock gets automatically release when the request ends (finishes or aborts)
public
static acquireLockForName(string $sName, int $iTimeout) : bool
Parameters
- $sName : string
-
The name of the lock to acquire
- $iTimeout : int
-
An optional timeout in seconds, for acquiring the lock. If set, this method will wait up to the defined timeout if the lock is not immediately available.
Tags
Return values
bool —True, if the lock has been acquired, otherwise false
acquireLockForRecord()
Acquires a lock for a record. This lock gets automatically released when the request ends (finishes or aborts)
public
static acquireLockForRecord(Record $oRecord, int $iTimeout) : bool
Parameters
- $oRecord : Record
-
The record for which the lock should be acquired.
- $iTimeout : int
-
An optional timeout in seconds. If set the lock gets automatically released after the timeout.
Tags
Return values
bool —True, if the lock has been acquired, otherwise false
canAcquireLockForName()
Checks if a lock with the specified name can be acquired. If the lock should also be acquired, please use "acquireLockForName" directly, as this requires only 1 query, instead of 2.
public
static canAcquireLockForName(string $sName) : bool
Parameters
- $sName : string
-
The name of the lock to check
Tags
Return values
bool —True, if the lock can be acquired, otherwise false
canAcquireLockForRecord()
Checks if a lock for a record can be acquired. If the lock should also be acquired, please use "acquireLockForRecord" directly, as this requires only 1 query, instead of 2.
public
static canAcquireLockForRecord(Record $oRecord) : bool
Parameters
- $oRecord : Record
-
The record for which the lock should be checked.
Tags
Return values
bool —True, if the lock can be acquired, otherwise false
releaseLockForName()
Releases a lock previously acquired with acquireLockForName.
public
static releaseLockForName(string $sName) : bool
Parameters
- $sName : string
-
The name of the lock to release
Tags
Return values
bool —True, if the lock has been released, otherwise false
releaseLockForRecord()
Releases a lock for a record previously acquired with acquireLockForRecord.
public
static releaseLockForRecord(Record $oRecord) : bool
Parameters
- $oRecord : Record
-
The record for which the lock should be released.
Tags
Return values
bool —True, if the lock has been released, otherwise false
