Throttling functions

更新时间:
复制 MD 格式

This topic describes the syntax, parameters, return values, and examples for throttling functions.

limit_rate_after

ItemDescription
Syntaxlimit_rate_after(n, unit)
DescriptionSpecifies the amount of data to transfer before rate limiting begins.
Note This function applies to an individual request and is not a global bandwidth limit.
Parameters
  • unit: An integer. If you do not specify the parameter, the default unit is bytes.
  • unitKMG: A char. Valid values are , , or . The values are case-insensitive.
Return valuetruefalseReturns on success or on failure.
Examples
limit_rate_after(10, 'k')
limit_rate(1, 'm') 
// After the first 10 KB is transferred, the rate is limited to 1 MB/s.

limit_rate

ItemDescription
Syntaxlimit_rate(n, unit)
DescriptionSets the data transfer rate limit. The minimum rate is 4 KB/s. If you specify a rate lower than 4 KB/s, the limit defaults to 4 KB/s.
Note This function applies to an individual request and is not a global bandwidth limit.
Parameters
  • unit: An integer. If you do not specify the parameter, the default unit is bytes/s.
  • unitKMG: A char. Valid values are , , or . The values are case-insensitive.
Return valuetruefalseReturns on success or on failure.
Examples
limit_rate(500, 'k')
// Limits the data transfer rate to 500 KB/s.