Conditions | 1 |
Paths | 1 |
Total Lines | 20 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 1 |
Changes | 0 |
1 | <?php |
||
36 | 2 | public function process(): int |
|
37 | { |
||
38 | $script = <<<LUA |
||
39 | 2 | local limit, timestamp = ... |
|
40 | local counter = 0 |
||
41 | box.begin() |
||
42 | 2 | box.space.$this->space.index.expire:pairs() |
|
43 | :take_while(function(tuple) return counter < limit end) |
||
44 | :take_while(function(tuple) return tuple.expire <= timestamp end) |
||
45 | :each(function(tuple) |
||
46 | 2 | box.space.$this->space:delete( tuple.key ) |
|
47 | counter = counter + 1 |
||
48 | end) |
||
49 | box.commit() |
||
50 | return counter |
||
51 | LUA; |
||
52 | |||
53 | 2 | [$counter] = $this->client->evaluate($script, $this->limit, microtime(true)); |
|
54 | |||
55 | 2 | return $counter; |
|
56 | } |
||
58 |