@@ -34,13 +34,13 @@ composer require cybercog/php-db-locker
34
34
``` php
35
35
$dbConnection = new PDO($dsn, $username, $password);
36
36
37
- $postgresLocker = new \Cog\DbLocker\Locker\PostgresAdvisoryLocker();
38
- $postgresLockId = \Cog\DbLocker\LockId\PostgresLockId::fromKeyValue('user', '4');
37
+ $locker = new \Cog\DbLocker\Locker\PostgresAdvisoryLocker();
38
+ $lockId = \Cog\DbLocker\LockId\PostgresLockId::fromKeyValue('user', '4');
39
39
40
40
$dbConnection->beginTransaction();
41
- $isLockAcquired = $postgresLocker ->acquireTransactionLevelLock(
41
+ $isLockAcquired = $locker ->acquireTransactionLevelLock(
42
42
$dbConnection,
43
- $postgresLockId ,
43
+ $lockId ,
44
44
\Cog\DbLocker\Locker\PostgresAdvisoryLockLevelEnum::Transaction,
45
45
\Cog\DbLocker\Locker\PostgresAdvisoryLockTypeEnum::NonBlocking,
46
46
\Cog\DbLocker\Locker\PostgresLockModeEnum::Exclusive,
@@ -58,12 +58,12 @@ $dbConnection->commit();
58
58
``` php
59
59
$dbConnection = new PDO($dsn, $username, $password);
60
60
61
- $postgresLocker = new \Cog\DbLocker\Locker\PostgresAdvisoryLocker();
62
- $postgresLockId = \Cog\DbLocker\LockId\PostgresLockId::fromKeyValue('user', '4');
61
+ $locker = new \Cog\DbLocker\Locker\PostgresAdvisoryLocker();
62
+ $lockId = \Cog\DbLocker\LockId\PostgresLockId::fromKeyValue('user', '4');
63
63
64
- $isLockAcquired = $postgresLocker ->acquireSessionLevelLock(
64
+ $isLockAcquired = $locker ->acquireSessionLevelLock(
65
65
$dbConnection,
66
- $postgresLockId ,
66
+ $lockId ,
67
67
\Cog\DbLocker\Locker\PostgresAdvisoryLockLevelEnum::Session,
68
68
\Cog\DbLocker\Locker\PostgresAdvisoryLockTypeEnum::NonBlocking,
69
69
\Cog\DbLocker\Locker\PostgresLockModeEnum::Exclusive,
@@ -73,7 +73,7 @@ if ($isLockAcquired) {
73
73
} else {
74
74
// Execute logic if lock acquisition has been failed
75
75
}
76
- $postgresLocker ->releaseSessionLevelLock($dbConnection, $postgresLockId );
76
+ $locker ->releaseSessionLevelLock($dbConnection, $lockId );
77
77
```
78
78
79
79
## Changelog
0 commit comments