\Yansongda\Supports\TraitsShouldThrottle

Trait ShouldThrottle.

Summary

Methods
Properties
Constants
isThrottled()
throttleAdd()
getThrottleResetTime()
getThrottleInfo()
getThrottleCounts()
$redis
No constants found
No protected methods found
$_throttle
N/A
No private methods found
No private properties found
N/A

Properties

$redis

$redis : \Predis\Client

Type

\Predis\Client

$_throttle

$_throttle : array

_throttle.

Type

array

Methods

isThrottled()

isThrottled(string  $key, integer  $limit = 60, integer  $period = 60, boolean  $auto_add = false) : boolean

isThrottled.

Parameters

string $key
integer $limit
integer $period
boolean $auto_add

Returns

boolean

throttleAdd()

throttleAdd(string  $key, integer  $period = 60) 

限流 + 1.

Parameters

string $key
integer $period

getThrottleResetTime()

getThrottleResetTime(  $key,   $now) : integer

getResetTime.

Parameters

$key
$now

Returns

integer

getThrottleInfo()

getThrottleInfo(string|null  $key = null, mixed|null  $default = null) : array|null

获取限流相关信息.

Parameters

string|null $key
mixed|null $default

Returns

array|null

getThrottleCounts()

getThrottleCounts(string  $key, integer  $period = 60) : string

获取已使用次数.

Parameters

string $key
integer $period

Returns

string