\CodeIgniter\ThrottleThrottlerInterface

Expected behavior of a Throttler

Summary

Methods
Constants
check()
getTokenTime()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

check()

check(string  $key, integer  $capacity, integer  $seconds, integer  $cost) : boolean

Restricts the number of requests made by a single key within a set number of seconds.

Example:

if (! $throttler->checkIPAddress($request->ipAddress(), 60, MINUTE)) { die('You submitted over 60 requests within a minute.'); }

Parameters

string $key

The name to use as the "bucket" name.

integer $capacity

The number of requests the "bucket" can hold

integer $seconds

The time it takes the "bucket" to completely refill

integer $cost

The number of tokens this action uses.

Returns

boolean

getTokenTime()

getTokenTime() : integer

Returns the number of seconds until the next available token will be released for usage.

Returns

integer