| @@ 50-57 (lines=8) @@ | ||
| 47 | $this->store[$key]['current']++; |
|
| 48 | } |
|
| 49 | ||
| 50 | protected function ttl(string $key) : int |
|
| 51 | { |
|
| 52 | if (!isset($this->store[$key])) { |
|
| 53 | return 0; |
|
| 54 | } |
|
| 55 | ||
| 56 | return max($this->store[$key]['expires'] - time(), 0); |
|
| 57 | } |
|
| 58 | ||
| 59 | private function has(string $key) : bool |
|
| 60 | { |
|
| @@ 64-71 (lines=8) @@ | ||
| 61 | return array_key_exists($key, $this->store); |
|
| 62 | } |
|
| 63 | ||
| 64 | private function hasExpired(string $key) : bool |
|
| 65 | { |
|
| 66 | if (!isset($this->store[$key]['expires'])) { |
|
| 67 | return false; |
|
| 68 | } |
|
| 69 | ||
| 70 | return time() > $this->store[$key]['expires']; |
|
| 71 | } |
|
| 72 | } |
|
| 73 | ||