class Illuminate / Cache / RateLimiter
You are viewing an older version of the documentation. For the latest, please visit master documentation.

RateLimiter

Uses

Properties

protected

$cache Repository

The cache store implementation.

Default: null
protected

$limiters array

The configured limit object resolvers.

Default: []

Methods

public

__construct ( Repository $cache ) : void

Create a new rate limiter instance.

Parameters

public

for ( string $name , Closure $callback ) : $this

Register a named limiter configuration.

Parameters

public

limiter ( string $name ) : Closure

Get the given named rate limiter.

Parameters

  • $name string
public

attempt ( $key , $maxAttempts , Closure $callback , $decaySeconds ) : mixed

Attempts to execute a callback if it's not limited.

Parameters

  • $key string
  • $maxAttempts int
  • $callback Closure
  • $decaySeconds int
public

tooManyAttempts ( $key , $maxAttempts ) : bool

Determine if the given key has been "accessed" too many times.

Parameters

  • $key string
  • $maxAttempts int
public

hit ( $key , $decaySeconds ) : int

Increment the counter for a given key for a given decay time.

Parameters

  • $key string
  • $decaySeconds int
public

attempts ( $key ) : mixed

Get the number of attempts for the given key.

Parameters

  • $key string
public

resetAttempts ( $key ) : mixed

Reset the number of attempts for the given key.

Parameters

  • $key string
public

remaining ( $key , $maxAttempts ) : int

Get the number of retries left for the given key.

Parameters

  • $key string
  • $maxAttempts int
public

retriesLeft ( $key , $maxAttempts ) : int

Get the number of retries left for the given key.

Parameters

  • $key string
  • $maxAttempts int
public

clear ( $key ) : void

Clear the hits and lockout timer for the given key.

Parameters

  • $key string
public

availableIn ( $key ) : int

Get the number of seconds until the "key" is accessible again.

Parameters

  • $key string
public

cleanRateLimiterKey ( $key ) : string

Clean the rate limiter key from unicode characters.

Parameters

  • $key string