1 | <?php |
||
37 | class PgsqlMutex extends DbMutex |
||
38 | { |
||
39 | /** |
||
40 | * Initializes PgSQL specific mutex component implementation. |
||
41 | * @throws InvalidConfigException if [[db]] is not PgSQL connection. |
||
42 | */ |
||
43 | 2 | public function init() |
|
44 | { |
||
45 | 2 | parent::init(); |
|
46 | 2 | if ($this->db->driverName !== 'pgsql') { |
|
47 | throw new InvalidConfigException('In order to use PgsqlMutex connection must be configured to use PgSQL database.'); |
||
48 | } |
||
49 | 2 | } |
|
50 | |||
51 | /** |
||
52 | * Converts a string into two 16 bit integer keys using the SHA1 hash function. |
||
53 | * @param string $name |
||
54 | * @return array contains two 16 bit integer keys |
||
55 | */ |
||
56 | 2 | private function getKeysFromName($name) |
|
60 | |||
61 | /** |
||
62 | * Acquires lock by given name. |
||
63 | * @param string $name of the lock to be acquired. |
||
64 | * @param int $timeout to wait for lock to become released. |
||
65 | * @return bool acquiring result. |
||
66 | * @see http://www.postgresql.org/docs/9.0/static/functions-admin.html |
||
67 | */ |
||
68 | 2 | protected function acquireLock($name, $timeout = 0) |
|
78 | |||
79 | /** |
||
80 | * Releases lock by given name. |
||
81 | * @param string $name of the lock to be released. |
||
82 | * @return bool release result. |
||
83 | * @see http://www.postgresql.org/docs/9.0/static/functions-admin.html |
||
84 | */ |
||
85 | 1 | protected function releaseLock($name) |
|
92 | } |
||
93 |