1 | <?php |
||
8 | class Redis implements StorageInterface |
||
9 | { |
||
10 | /** |
||
11 | * @var \Predis\Client |
||
12 | */ |
||
13 | protected $client; |
||
14 | |||
15 | 5 | public function __construct(Client $client) |
|
19 | |||
20 | 3 | public function getRateInfo($key) |
|
21 | { |
||
22 | 3 | $info = $this->client->hgetall($key); |
|
23 | |||
24 | 3 | $rateLimitInfo = new RateLimitInfo(); |
|
25 | 3 | $rateLimitInfo->setLimit($info['limit']); |
|
26 | 3 | $rateLimitInfo->setCalls($info['calls']); |
|
27 | 3 | $rateLimitInfo->setResetTimestamp($info['reset']); |
|
28 | |||
29 | 3 | return $rateLimitInfo; |
|
30 | } |
||
31 | |||
32 | 2 | public function limitRate($key) |
|
42 | |||
43 | 1 | public function createRate($key, $limit, $period) |
|
52 | |||
53 | 1 | public function resetRate($key) |
|
58 | } |
||
59 |