\CodeIgniter\ThrottleThrottler

Class Throttler

Uses an implementation of the Token Bucket algorithm to implement a "rolling window" type of throttling that can be used for rate limiting an API or any other request.

Each "token" in the "bucket" is equivalent to a single request for the purposes of this implementation.

Summary

Methods
Properties
Constants
__construct()
getTokenTime()
setTestTime()
time()
No public properties found
No constants found
No protected methods found
$cache
$tokenTime
$prefix
$testTime
N/A
No private methods found
No private properties found
N/A

Properties

$tokenTime

$tokenTime : integer

The number of seconds until the next token is available.

Type

integer

$prefix

$prefix : string

The prefix applied to all keys to minimize potential conflicts.

Type

string

$testTime

$testTime : integer

Timestamp to use (during testing)

Type

integer

Methods

__construct()

__construct(\CodeIgniter\Throttle\type  $cache) 

Constructor.

Parameters

\CodeIgniter\Throttle\type $cache

Throws

\CodeIgniter\Throttle\type

getTokenTime()

getTokenTime() : integer

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

Returns

integer

setTestTime()

setTestTime(integer  $time) : $this

Used during testing to set the current timestamp to use.

Parameters

integer $time

Returns

$this

time()

time() : integer

Return the test time, defaulting to current.

Returns

integer