1 | <?php |
||
9 | abstract class AbstractTTLRateLimiter implements RateLimiter, SilentRateLimiter |
||
10 | { |
||
11 | /** @var string */ |
||
12 | private $keyPrefix; |
||
13 | |||
14 | 10 | public function __construct(string $keyPrefix = '') |
|
18 | |||
19 | 4 | final public function limit(string $identifier, Rate $rate): void |
|
30 | |||
31 | 6 | final public function limitSilently(string $identifier, Rate $rate): Status |
|
47 | |||
48 | 10 | private function key(string $identifier, int $interval): string |
|
52 | |||
53 | abstract protected function getCurrent(string $key): int; |
||
54 | |||
55 | abstract protected function updateCounter(string $key, int $interval): int; |
||
56 | |||
57 | abstract protected function ttl(string $key): int; |
||
58 | } |
||
59 |