decayMinutes
- 制限時間内にカウントされます。技術的な制限は、TTL(Time To Live)の値を$decayMinutes * 60
秒に設定し、ヒットごとにインクリメントするキャッシュです。 TTLが値を超えると、キャッシュ内で自動的に破棄され、新しいヒット数が開始されます。
RateLimit::hit()コードをご覧ください。それはかなり明らかだ:
/**
* Increment the counter for a given key for a given decay time.
*
* @param string $key
* @param float|int $decayMinutes
* @return int
*/
public function hit($key, $decayMinutes = 1)
{
$this->cache->add(
$key.':timer', $this->availableAt($decayMinutes * 60), $decayMinutes
);
$added = $this->cache->add($key, 0, $decayMinutes);
$hits = (int) $this->cache->increment($key);
if (! $added && $hits == 1) {
$this->cache->put($key, 1, $decayMinutes);
}
return $hits;
}
あなたはdecayMinutes
は、ソースコードを読むことから5.
でなければならないよりも、5分ごとに10本のヒットによって、いくつかの活動を制限したい場合は、これはあまりにも私の理解です。 – fubar
これは間違った答えです。 'decayMinutes'(Laravel 5.5)はブロック時間ではありません。 –
私はログインブロック時間が一例だと思っていますが、スロットルのためにほとんど同じ方法で動作します。 「ログイン試行」を「要求された一意のURL」に置き換えてください。 $ decayMinutes分のページまたはAPIリクエストをしないと、スロットルカウンタがリセットされます。 –