RateLimit::__construct
制限を作成します
説明
public RateLimit::__construct( string $bucket, int $max, int $window )
$window秒の間に$max回までという制限を作成します。キーはバケットごとに別々に数えます。
$bucketが空か64文字より長いとき、$maxか$windowが1未満のときは\InvalidArgumentExceptionを投げます。
引数
| 名前 | データ型 | デフォルト | 備考 |
|---|---|---|---|
| $bucket | string | 制限の名前(1〜64文字)。'contact'、'cms-login'など | |
| $max | int | 期間内に許す試行の回数 | |
| $window | int | 秒数 |
例
Controller
use Fegg\Tool\RateLimit;
$perHour = new RateLimit('entry', 5, 3600); // 5 an hour
$perDay = new RateLimit('entry-day', 20, 86400); // and 20 a day