Conditions | 3 |
Paths | 3 |
Total Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php |
||
32 | public function lock($name, $ttl = 1) |
||
33 | { |
||
34 | if (in_array($name, $this->locks)) { |
||
35 | throw new Exception("Lock $name was already registered"); |
||
36 | } |
||
37 | $result = $this->redis->set("lock-$name", 1, 'EX', $ttl, 'NX'); |
||
38 | if ($result) { |
||
39 | $this->locks[] = $name; |
||
40 | return true; |
||
41 | } |
||
42 | return false; |
||
43 | } |
||
44 | |||
77 |