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 | */ |
||
44 | public function __construct($user, $password, $host, $port = 3306, $classname = 'PDO', $ssl_ca_cert = NULL) |
||
55 | |||
56 | 10 | public function __clone() |
|
61 | |||
62 | /** |
||
63 | * Acquire lock |
||
64 | * |
||
65 | * @param string $name name of lock |
||
66 | * @param null|int $timeout 1. null if you want blocking lock |
||
67 | * 2. 0 if you want just lock and go |
||
68 | * 3. $timeout > 0 if you want to wait for lock some time (in milliseconds) |
||
69 | * @return bool |
||
70 | */ |
||
71 | 32 | public function acquireLock($name, $timeout = null) |
|
79 | |||
80 | /** |
||
81 | * @param string $name |
||
82 | * @param bool $blocking |
||
83 | * @return bool |
||
84 | */ |
||
85 | 32 | protected function getLock($name, $blocking) |
|
97 | |||
98 | /** |
||
99 | * Release lock |
||
100 | * |
||
101 | * @param string $name name of lock |
||
102 | * @return bool |
||
103 | */ |
||
104 | 32 | public function releaseLock($name) |
|
128 | |||
129 | /** |
||
130 | * Check if lock is locked |
||
131 | * |
||
132 | * @param string $name name of lock |
||
133 | * @return bool |
||
134 | */ |
||
135 | 32 | public function isLocked($name) |
|
150 | |||
151 | /** |
||
152 | * @param string $name |
||
153 | * @return bool |
||
154 | */ |
||
155 | 32 | protected function setupPDO($name) |
|
174 | |||
175 | 10 | public function __destruct() |
|
183 | } |
||
184 |