| @@ 62-73 (lines=12) @@ | ||
| 59 | /** |
|
| 60 | * @inheritdoc |
|
| 61 | */ |
|
| 62 | public function count() |
|
| 63 | { |
|
| 64 | try { |
|
| 65 | if (($this->timeProvider->now() - $this->cache->get($this->key.self::TIME_CACHE_KEY)) > $this->timeLimit) { |
|
| 66 | return 0; |
|
| 67 | } |
|
| 68 | ||
| 69 | return $this->getCachedHitCount(); |
|
| 70 | } catch (ItemNotFoundException $exception) { |
|
| 71 | return 0; |
|
| 72 | } |
|
| 73 | } |
|
| 74 | ||
| 75 | /** |
|
| 76 | * @inheritdoc |
|
| @@ 87-96 (lines=10) @@ | ||
| 84 | /** |
|
| 85 | * @inheritdoc |
|
| 86 | */ |
|
| 87 | public function getRetryTimeout() |
|
| 88 | { |
|
| 89 | if ($this->check()) { |
|
| 90 | return 0; |
|
| 91 | } |
|
| 92 | ||
| 93 | // Return the time until the current window ends |
|
| 94 | // Try/catch for the ItemNotFoundException is not required, in that case $this->check() will return true |
|
| 95 | return 1e3 * ($this->timeLimit - $this->timeProvider->now() + $this->cache->get($this->key.self::TIME_CACHE_KEY)); |
|
| 96 | } |
|
| 97 | ||
| 98 | /** |
|
| 99 | * @return int |
|