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 | |||
35 | /** |
||
36 | * Provide data for PDO connection |
||
37 | * |
||
38 | * @param string $user |
||
39 | * @param string $password |
||
40 | * @param string $host |
||
41 | * @param int $port |
||
42 | * @param string $classname class name to create as PDO connection |
||
43 | * @param string $ssl_ca_cert Path to a file containing the SSL CA certificate(s), if you'd like to connect using SSL |
||
44 | */ |
||
45 | public function __construct($user, $password, $host, $port = 3306, $classname = 'PDO', $ssl_ca_cert = NULL) |
||
56 | |||
57 | 10 | public function __clone() |
|
62 | |||
63 | /** |
||
64 | * Acquire lock |
||
65 | * |
||
66 | * @param string $name name of lock |
||
67 | * @param null|int $timeout 1. null if you want blocking lock |
||
68 | * 2. 0 if you want just lock and go |
||
69 | * 3. $timeout > 0 if you want to wait for lock some time (in milliseconds) |
||
70 | * @return bool |
||
71 | */ |
||
72 | 32 | public function acquireLock($name, $timeout = null) |
|
80 | |||
81 | /** |
||
82 | * @param string $name |
||
83 | * @param bool $blocking |
||
84 | * @return bool |
||
85 | */ |
||
86 | 32 | protected function getLock($name, $blocking) |
|
98 | |||
99 | /** |
||
100 | * Release lock |
||
101 | * |
||
102 | * @param string $name name of lock |
||
103 | * @return bool |
||
104 | */ |
||
105 | 32 | public function releaseLock($name) |
|
129 | |||
130 | /** |
||
131 | * Check if lock is locked |
||
132 | * |
||
133 | * @param string $name name of lock |
||
134 | * @return bool |
||
135 | */ |
||
136 | 32 | public function isLocked($name) |
|
151 | |||
152 | /** |
||
153 | * @param string $name |
||
154 | * @return bool |
||
155 | */ |
||
156 | 32 | protected function setupPDO($name) |
|
175 | |||
176 | 10 | public function __destruct() |
|
184 | } |
||
185 |