PHP Class Stiphle\Throttle\TimeWindow

Author: Dave Marshall ([email protected])
Inheritance: implements Stiphle\Throttle\ThrottleInterface
Mostrar archivo Open project: davedevelopment/stiphle

Protected Properties

Property Type Description
$storage Stiphle\Storage\StorageInterface

Public Methods

Method Description
__construct ( )
getEstimate ( string $key, integer $limit, integer $milliseconds ) : integer Get Estimate (doesn't require lock)
setStorage ( Stiphle\Storage\StorageInterface $storage ) : LeakyBucket Set Storage
throttle ( string $key, integer $limit, integer $milliseconds ) : void Throttle

Protected Methods

Method Description
getStorageKey ( string $key, integer $limit, integer $milliseconds ) : string Get storage key

Method Details

__construct() public method

public __construct ( )

getEstimate() public method

How long would I have to wait to make a request?
public getEstimate ( string $key, integer $limit, integer $milliseconds ) : integer
$key string - A unique key for what we're throttling
$limit integer - How many are allowed
$milliseconds integer - In this many milliseconds
return integer - the number of milliseconds before this request should be allowed to pass

getStorageKey() protected method

Get storage key
protected getStorageKey ( string $key, integer $limit, integer $milliseconds ) : string
$key string - A unique key for what we're throttling
$limit integer - How many are allowed
$milliseconds integer - In this many milliseconds
return string

setStorage() public method

Set Storage
public setStorage ( Stiphle\Storage\StorageInterface $storage ) : LeakyBucket
$storage Stiphle\Storage\StorageInterface
return LeakyBucket

throttle() public method

Throttle
public throttle ( string $key, integer $limit, integer $milliseconds ) : void
$key string - A unique key for what we're throttling
$limit integer - How many are allowed
$milliseconds integer - In this many milliseconds
return void

Property Details

$storage protected_oe property

protected StorageInterface,Stiphle\Storage $storage
return Stiphle\Storage\StorageInterface