1 | <?php |
||
9 | final class RedisRateLimiter extends AbstractTTLRateLimiter |
||
10 | { |
||
11 | /** @var Redis */ |
||
12 | private $redis; |
||
13 | |||
14 | 5 | public function __construct(Redis $predis, string $keyPrefix = '') |
|
15 | { |
||
16 | 5 | if (!\extension_loaded('redis')) { |
|
17 | throw new \RuntimeException('Redis extension is not loaded.'); |
||
18 | } |
||
19 | |||
20 | 5 | parent::__construct($keyPrefix); |
|
21 | |||
22 | 5 | $this->redis = $predis; |
|
23 | 5 | } |
|
24 | |||
25 | 5 | protected function getCurrent(string $key): int |
|
29 | |||
30 | 5 | protected function updateCounter(string $key, int $interval): int |
|
40 | |||
41 | 3 | protected function ttl(string $key): int |
|
45 | } |
||
46 |