Snuze  0.8.1
snuze\RateLimitBucket Class Reference
Inheritance diagram for snuze\RateLimitBucket:

Public Member Functions

 __construct ()
 
 getRemaining ()
 
 getRefillTime ()
 
 isEmpty ()
 
 drip ()
 
 update (int $remaining, int $secondsUntilRefill)
 
- Public Member Functions inherited from snuze\SnuzeObject
 __construct (array $args=null)
 
 _getSnuzeId ()
 
 _getSnuzeClass ()
 
 _ident ()
 

Public Attributes

const BUCKET_VOLUME = 600
 

Private Attributes

 $remaining = self::BUCKET_VOLUME
 
 $refillTime = 0
 

Additional Inherited Members

- Protected Member Functions inherited from snuze\SnuzeObject
 debug (string $message, bool $echo=false)
 
 info (string $message, bool $echo=false)
 
 warning (string $message, bool $echo=false)
 
 error (string $message, bool $echo=false)
 
- Protected Attributes inherited from snuze\SnuzeObject
 $_snuzeId = null
 
 $_snuzeClass = null
 

Detailed Description

The RateLimitBucket represents the state of Reddit's API rate limit mechanism.

Reddit divides each hour into six ten-minute slices, and allows authenticated users to issue a limited number of API requests during each slice. When your allotment for the current time slice has been exhausted, no more requests are permitted until the next time slice begins. The rate limit resets every ten minutes (:00, :10, etc.), refilling the bucket.


This file is part of Snuze, a PHP client for the Reddit API. Copyright 2019 Shaun Cummiskey shaun.nosp@m.@sha.nosp@m.unc.c.nosp@m.om https://shaunc.com/ Repository: https://github.com/snuze/snuze/ Documentation: https://snuze.shaunc.com/

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Constructor & Destructor Documentation

◆ __construct()

snuze\RateLimitBucket::__construct ( )

Constructor.

Member Function Documentation

◆ drip()

snuze\RateLimitBucket::drip ( )

Decrement the value of $remaining by one.

Returns
void

◆ getRefillTime()

snuze\RateLimitBucket::getRefillTime ( )

Get the unix epoch time at which the bucket will next be refilled

Returns
int

◆ getRemaining()

snuze\RateLimitBucket::getRemaining ( )

Get the number of requests remaining during this ten-minute period

Returns
int

◆ isEmpty()

snuze\RateLimitBucket::isEmpty ( )

Get whether or not the bucket is currently empty

Returns
bool

◆ update()

snuze\RateLimitBucket::update ( int  $remaining,
int  $secondsUntilRefill 
)

Update the bucket state

Parameters
int$remainingThe number of requests remaining during this ten-minute period
int$secondsUntilRefillThe number of seconds until the bucket will be refilled

Member Data Documentation

◆ BUCKET_VOLUME

const snuze\RateLimitBucket::BUCKET_VOLUME = 600

How many requests the bucket holds when it's full. The default is 600.


The documentation for this class was generated from the following file: