File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,30 @@ $dbConnection->commit();
5454
5555#### Session-level advisory lock
5656
57+ Callback API
58+
59+ ``` php
60+ $dbConnection = new PDO($dsn, $username, $password);
61+
62+ $locker = new \Cog\DbLocker\Postgres\PostgresAdvisoryLocker();
63+ $lockId = \Cog\DbLocker\Postgres\PostgresLockKey::create('user', '4');
64+
65+ $lock = $locker->withinSessionLevelLock(
66+ $dbConnection,
67+ $lockId,
68+ function (\Cog\DbLocker\Postgres\LockHandle\SessionLevelLockHandle $lock): Payment {
69+ if ($lock->wasAcquired) {
70+ // Execute logic if lock was successful
71+ } else {
72+ // Execute logic if lock acquisition has been failed
73+ }
74+ }
75+ \Cog\DbLocker\Postgres\Enum\PostgresLockWaitModeEnum::NonBlocking,
76+ \Cog\DbLocker\Postgres\Enum\PostgresLockAccessModeEnum::Exclusive,
77+ );
78+ ```
79+
80+ Low-level API
5781``` php
5882$dbConnection = new PDO($dsn, $username, $password);
5983
You can’t perform that action at this time.
0 commit comments