PHP Класс Dingo\Api\Http\RateLimit\Handler

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$cache Illuminate\Cache\CacheManager Cache instance.
$container Illuminate\Container\Container Container instance.
$keyPrefix string The key prefix used when throttling route specific requests.
$limiter callback A callback used to define the limiter.
$request Dingo\Api\Http\Request Request instance being throttled.
$throttle Dingo\Api\Contract\Http\RateLimit\Throttle Throttle used for rate limiting.
$throttles Illuminate\Support\Collection Registered throttles.

Открытые методы

Метод Описание
__construct ( Illuminate\Container\Container $container, Illuminate\Cache\CacheManager $cache, array $throttles ) : void Create a new rate limit handler instance.
exceededRateLimit ( ) : boolean Determine if the rate limit has been exceeded.
extend ( callable | Dingo\Api\Http\RateLimit\Throttle $throttle ) : void Extend the rate limiter by adding a new throttle.
getRateLimitReset ( ) : integer Get the timestamp for when the current rate limiting will expire.
getRateLimiter ( ) : string Get the rate limiter.
getRemainingLimit ( ) : integer Get the remaining limit before the consumer is rate limited.
getThrottle ( ) : Dingo\Api\Contract\Http\RateLimit\Throttle Get the throttle used to rate limit the request.
getThrottleLimit ( ) : integer Get the limit of the throttle used.
rateLimitRequest ( Dingo\Api\Http\Request $request, integer $limit, integer $expires ) : void Execute the rate limiting for the given request.
requestWasRateLimited ( ) : boolean Determine if the request was rate limited.
setRateLimiter ( callable $limiter ) : void Set the rate limiter.
setThrottle ( string | Dingo\Api\Contract\Http\RateLimit\Throttle $throttle ) : void Set the throttle to use for rate limiting.

Защищенные методы

Метод Описание
cache ( string $key, mixed $value, integer $minutes ) : void Cache a value under a given key for a certain amount of minutes.
forget ( string $key ) : void Forget a key in the cache.
getMatchingThrottles ( ) : Collection Get matching throttles after executing the condition of each throttle.
increment ( string $key ) : void Increment a key in the cache.
key ( string $key ) : string Namespace a cache key.
prepareCacheStore ( ) : void Prepare the cache store.
retrieve ( string $key ) : mixed Retrieve a value from the cache store.

Описание методов

__construct() публичный Метод

Create a new rate limit handler instance.
public __construct ( Illuminate\Container\Container $container, Illuminate\Cache\CacheManager $cache, array $throttles ) : void
$container Illuminate\Container\Container
$cache Illuminate\Cache\CacheManager
$throttles array
Результат void

cache() защищенный Метод

Cache a value under a given key for a certain amount of minutes.
protected cache ( string $key, mixed $value, integer $minutes ) : void
$key string
$value mixed
$minutes integer
Результат void

exceededRateLimit() публичный Метод

Determine if the rate limit has been exceeded.
public exceededRateLimit ( ) : boolean
Результат boolean

extend() публичный Метод

Extend the rate limiter by adding a new throttle.
public extend ( callable | Dingo\Api\Http\RateLimit\Throttle $throttle ) : void
$throttle callable | Dingo\Api\Http\RateLimit\Throttle
Результат void

forget() защищенный Метод

Forget a key in the cache.
protected forget ( string $key ) : void
$key string
Результат void

getMatchingThrottles() защищенный Метод

Get matching throttles after executing the condition of each throttle.
protected getMatchingThrottles ( ) : Collection
Результат Illuminate\Support\Collection

getRateLimitReset() публичный Метод

Get the timestamp for when the current rate limiting will expire.
public getRateLimitReset ( ) : integer
Результат integer

getRateLimiter() публичный Метод

Get the rate limiter.
public getRateLimiter ( ) : string
Результат string

getRemainingLimit() публичный Метод

Get the remaining limit before the consumer is rate limited.
public getRemainingLimit ( ) : integer
Результат integer

getThrottle() публичный Метод

Get the throttle used to rate limit the request.
public getThrottle ( ) : Dingo\Api\Contract\Http\RateLimit\Throttle
Результат Dingo\Api\Contract\Http\RateLimit\Throttle

getThrottleLimit() публичный Метод

Get the limit of the throttle used.
public getThrottleLimit ( ) : integer
Результат integer

increment() защищенный Метод

Increment a key in the cache.
protected increment ( string $key ) : void
$key string
Результат void

key() защищенный Метод

Namespace a cache key.
protected key ( string $key ) : string
$key string
Результат string

prepareCacheStore() защищенный Метод

Prepare the cache store.
protected prepareCacheStore ( ) : void
Результат void

rateLimitRequest() публичный Метод

Execute the rate limiting for the given request.
public rateLimitRequest ( Dingo\Api\Http\Request $request, integer $limit, integer $expires ) : void
$request Dingo\Api\Http\Request
$limit integer
$expires integer
Результат void

requestWasRateLimited() публичный Метод

Determine if the request was rate limited.
public requestWasRateLimited ( ) : boolean
Результат boolean

retrieve() защищенный Метод

Retrieve a value from the cache store.
protected retrieve ( string $key ) : mixed
$key string
Результат mixed

setRateLimiter() публичный Метод

Set the rate limiter.
public setRateLimiter ( callable $limiter ) : void
$limiter callable
Результат void

setThrottle() публичный Метод

Set the throttle to use for rate limiting.
public setThrottle ( string | Dingo\Api\Contract\Http\RateLimit\Throttle $throttle ) : void
$throttle string | Dingo\Api\Contract\Http\RateLimit\Throttle
Результат void

Описание свойств

$cache защищенное свойство

Cache instance.
protected CacheManager,Illuminate\Cache $cache
Результат Illuminate\Cache\CacheManager

$container защищенное свойство

Container instance.
protected Container,Illuminate\Container $container
Результат Illuminate\Container\Container

$keyPrefix защищенное свойство

The key prefix used when throttling route specific requests.
protected string $keyPrefix
Результат string

$limiter защищенное свойство

A callback used to define the limiter.
protected callback $limiter
Результат callback

$request защищенное свойство

Request instance being throttled.
protected Request,Dingo\Api\Http $request
Результат Dingo\Api\Http\Request

$throttle защищенное свойство

Throttle used for rate limiting.
protected Throttle,Dingo\Api\Contract\Http\RateLimit $throttle
Результат Dingo\Api\Contract\Http\RateLimit\Throttle

$throttles защищенное свойство

Registered throttles.
protected Collection,Illuminate\Support $throttles
Результат Illuminate\Support\Collection