1 | <?php |
||
37 | class PgsqlMutex extends DbMutex |
||
38 | { |
||
39 | use RetryAcquireTrait; |
||
40 | |||
41 | /** |
||
42 | * Initializes PgSQL specific mutex component implementation. |
||
43 | * @throws InvalidConfigException if [[db]] is not PgSQL connection. |
||
44 | */ |
||
45 | 10 | public function init() |
|
52 | |||
53 | /** |
||
54 | * Converts a string into two 16 bit integer keys using the SHA1 hash function. |
||
55 | * @param string $name |
||
56 | * @return array contains two 16 bit integer keys |
||
57 | */ |
||
58 | 10 | private function getKeysFromName($name) |
|
62 | |||
63 | /** |
||
64 | * Acquires lock by given name. |
||
65 | * @param string $name of the lock to be acquired. |
||
66 | * @param int $timeout time (in seconds) to wait for lock to become released. |
||
67 | * @return bool acquiring result. |
||
68 | * @see http://www.postgresql.org/docs/9.0/static/functions-admin.html |
||
69 | */ |
||
70 | 10 | protected function acquireLock($name, $timeout = 0) |
|
84 | |||
85 | /** |
||
86 | * Releases lock by given name. |
||
87 | * @param string $name of the lock to be released. |
||
88 | * @return bool release result. |
||
89 | * @see http://www.postgresql.org/docs/9.0/static/functions-admin.html |
||
90 | */ |
||
91 | 10 | protected function releaseLock($name) |
|
102 | } |
||
103 |