Длина строки не превышает 64 бита. в \bandwidth-throttle\token-bucket\classes\util\DoublePacker.php: 41
Эта ошибка при применении следующего кода в конструкторе ApiController и пытался использовать потребление:
Код: Выделить всё
function __construct() {
$this->storage = new FileStorage(__DIR__ . "/api.bucket");
$this->rate = new Rate(10, Rate::SECOND);
$this->bucket = new TokenBucket(10, $this->rate, $this->storage);
//Following code executed once, then commented
//$this->bucket->bootstrap(10);
}
Код: Выделить всё
protected function checkRateLimit() {
if (!$this->bucket->consume(1, $seconds)) {
http_response_code(429);
header(sprintf("Retry-After: %d", floor($seconds)));
exit();
}
//echo "Continue to API response";
return true;
}
Код: Выделить всё
bandwidthThrottle\tokenBucket\util\DoublePacker: :unpack('')
Подробнее здесь: https://stackoverflow.com/questions/784 ... pi-rate-li