| @@ 66-79 (lines=14) @@ | ||
| 63 | /** |
|
| 64 | * @inheritdoc |
|
| 65 | */ |
|
| 66 | public function count() |
|
| 67 | { |
|
| 68 | try { |
|
| 69 | /** @var CacheTime $currentItem */ |
|
| 70 | $currentItem = $this->cache->getItem($this->getTimeCacheKey()); |
|
| 71 | if (($this->timeProvider->now() - $currentItem->getTime()) > $this->timeLimit) { |
|
| 72 | return 0; |
|
| 73 | } |
|
| 74 | ||
| 75 | return $this->getCachedHitCount(); |
|
| 76 | } catch (ItemNotFoundException $exception) { |
|
| 77 | return 0; |
|
| 78 | } |
|
| 79 | } |
|
| 80 | ||
| 81 | /** |
|
| 82 | * @inheritdoc |
|
| @@ 94-106 (lines=13) @@ | ||
| 91 | /** |
|
| 92 | * @inheritdoc |
|
| 93 | */ |
|
| 94 | public function getRetryTimeout() |
|
| 95 | { |
|
| 96 | if ($this->check()) { |
|
| 97 | return 0; |
|
| 98 | } |
|
| 99 | ||
| 100 | // Return the time until the current window ends |
|
| 101 | // Try/catch for the ItemNotFoundException is not required, in that case $this->check() will return true |
|
| 102 | /** @var CacheTime $cachedTime */ |
|
| 103 | $cachedTime = $this->cache->getItem($this->getTimeCacheKey()); |
|
| 104 | ||
| 105 | return self::SECOND_TO_MILLISECOND_MULTIPLIER * ($this->timeLimit - $this->timeProvider->now() + $cachedTime->getTime()); |
|
| 106 | } |
|
| 107 | ||
| 108 | /** |
|
| 109 | * @return int |
|