1 | <?php |
||
19 | class MySqlLock extends LockAbstract |
||
20 | { |
||
21 | /** |
||
22 | * MySql connections |
||
23 | * |
||
24 | * @var PDO[] |
||
25 | */ |
||
26 | protected $pdo = array(); |
||
27 | |||
28 | protected $user; |
||
29 | protected $password; |
||
30 | protected $host; |
||
31 | protected $port; |
||
32 | protected $classname; |
||
33 | protected $ssl_ca_cert; |
||
34 | protected $ssl_verify_server_cert = true; |
||
35 | |||
36 | /** |
||
37 | * Provide data for PDO connection |
||
38 | * |
||
39 | * @param string $user |
||
40 | * @param string $password |
||
41 | * @param string $host |
||
42 | * @param int $port |
||
43 | * @param string $classname class name to create as PDO connection |
||
44 | * @param string $ssl_ca_cert Path to a file containing the SSL CA certificate(s), if you'd like to connect using SSL |
||
45 | * @param bool $ssl_verify_server_cert Indicate if you want to verify that the server certificate is valid. |
||
46 | */ |
||
47 | public function __construct($user, $password, $host, $port = 3306, $classname = 'PDO', $ssl_ca_cert = NULL, $ssl_verify_server_cert = true) |
||
59 | |||
60 | 5 | public function __clone() |
|
65 | |||
66 | /** |
||
67 | * Acquire lock |
||
68 | * |
||
69 | * @param string $name name of lock |
||
70 | * @param null|int $timeout 1. null if you want blocking lock |
||
71 | * 2. 0 if you want just lock and go |
||
72 | * 3. $timeout > 0 if you want to wait for lock some time (in milliseconds) |
||
73 | * @return bool |
||
74 | */ |
||
75 | 16 | public function acquireLock($name, $timeout = null) |
|
83 | |||
84 | /** |
||
85 | * @param string $name |
||
86 | * @param bool $blocking |
||
87 | * @return bool |
||
88 | */ |
||
89 | 16 | protected function getLock($name, $blocking) |
|
101 | |||
102 | /** |
||
103 | * Release lock |
||
104 | * |
||
105 | * @param string $name name of lock |
||
106 | * @return bool |
||
107 | */ |
||
108 | 16 | public function releaseLock($name) |
|
132 | |||
133 | /** |
||
134 | * Check if lock is locked |
||
135 | * |
||
136 | * @param string $name name of lock |
||
137 | * @return bool |
||
138 | */ |
||
139 | 16 | public function isLocked($name) |
|
154 | |||
155 | /** |
||
156 | * @param string $name |
||
157 | * @return bool |
||
158 | */ |
||
159 | 16 | protected function setupPDO($name) |
|
181 | |||
182 | 5 | public function __destruct() |
|
190 | } |
||
191 |