1 | <?php |
||
7 | final class ApcuRateLimiter extends AbstractElapsedTimeRateLimiter |
||
8 | { |
||
9 | public function __construct(string $keyPrefix = '') |
||
10 | { |
||
11 | if (!\extension_loaded('apcu')) { |
||
12 | throw new \RuntimeException('APCu extension is not loaded.'); |
||
13 | } |
||
14 | |||
15 | if (\ini_get('apc.use_request_time') === '1') { |
||
16 | throw new \RuntimeException('APCu ini configuration "apc.use_request_time" should be set to "0".'); |
||
17 | } |
||
18 | |||
19 | parent::__construct($keyPrefix); |
||
20 | } |
||
21 | |||
22 | protected function getCurrent(string $valueKey): int |
||
26 | |||
27 | protected function updateCounter(string $valueKey, string $timeKey, int $interval): int |
||
37 | |||
38 | protected function getElapsedTime(string $timeKey): int |
||
42 | } |
||
43 |