Conditions | 2 |
Paths | 2 |
Total Lines | 20 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
40 | public function tick($name, $timeout = 1) |
||
41 | { |
||
42 | $redis = $this->getConnection(); |
||
43 | $tickValue = 1; |
||
44 | $params = [ |
||
45 | $name, // Key name |
||
46 | $tickValue, // Key value |
||
47 | 'NX', // Set if Not eXists |
||
48 | 'EX', // Expire time |
||
49 | $timeout // Seconds |
||
50 | ]; |
||
51 | $response = $redis->executeCommand('SET', $params); |
||
52 | |||
53 | if ($response === true) { |
||
54 | |||
55 | return true; |
||
56 | } |
||
57 | |||
58 | return false; |
||
59 | } |
||
60 | |||
69 |