1 | <?php |
||
15 | class RedisMutex extends Mutex |
||
16 | { |
||
17 | |||
18 | /** |
||
19 | * @var \yii\redis\Connection |
||
20 | */ |
||
21 | public $redis; |
||
22 | |||
23 | /** |
||
24 | * Expire time, in seconds. |
||
25 | * |
||
26 | * @var int |
||
27 | */ |
||
28 | public $expireTime = 3; |
||
29 | |||
30 | /** |
||
31 | * @inheritdoc |
||
32 | * |
||
33 | * @throws \yii\base\InvalidConfigException |
||
34 | */ |
||
35 | 3 | public function init() |
|
41 | |||
42 | /** |
||
43 | * Acquires lock by given name. |
||
44 | * |
||
45 | * @param string $name of the lock to be acquired. |
||
46 | * @param integer $timeout to wait for lock to become released. |
||
47 | * |
||
48 | * @return boolean acquiring result. |
||
49 | */ |
||
50 | 3 | protected function acquireLock ($name, $timeout = 0) |
|
70 | |||
71 | /** |
||
72 | * Releases lock by given name. |
||
73 | * |
||
74 | * @param string $name of the lock to be released. |
||
75 | * |
||
76 | * @return boolean release result. |
||
77 | */ |
||
78 | 3 | protected function releaseLock ($name) |
|
99 | |||
100 | /** |
||
101 | * @return \yii\redis\Connection |
||
102 | */ |
||
103 | 3 | protected function getConnection() |
|
107 | |||
108 | /** |
||
109 | * @var float|false |
||
110 | */ |
||
111 | private $_lockValue = false; |
||
112 | |||
113 | /** |
||
114 | * @return float|mixed |
||
115 | */ |
||
116 | 3 | public function getLockValue() |
|
124 | } |
||
125 |