2017 © Pedro Peláez
 

library rate-limit

Rate Limiting for Amp.

image

kelunik/rate-limit

Rate Limiting for Amp.

  • Saturday, August 5, 2017
  • by kelunik
  • Repository
  • 2 Watchers
  • 8 Stars
  • 89 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 1 % Grown

The README.md

rate-limit

License, (*1)

kelunik/rate-limit is a rate limiting library for Amp., (*2)

Installation

composer require kelunik/rate-limit

Usage

You're in full control of any actions when the rate limit is exceeded. You can also already warn the user before he exceeds the limit., (*3)

$current = $this->rateLimit->increment("{$userId}:{$action}");

if ($current > $this->limit) {
    // show captcha or error page or do anything you want
} else {
    // request is within the limit, continue normally
}

If you want to expose the limits, e.g. in an HTTP API, you can also request the reset time for a given key., (*4)

$current = $this->rateLimit->increment("{$userId}:{$action}");

$response->setHeader("x-ratelimit-limit", $this->limit);
$response->setHeader("x-ratelimit-remaining", $this->limit - $current);
$response->setHeader("x-ratelimit-reset", $this->rateLimit->getTtl("{$userId}:{$action}"));

RateLimit::getTtl() returns the seconds until the limit is reset. If you want to return the absolute time, you can just add time() to that value., (*5)

The Versions

05/08 2017

dev-master

9999999-dev

Rate Limiting for Amp.

  Sources   Download

MIT

The Requires

 

The Development Requires

redis amp amphp limit rate-limit

05/08 2017

v2.0.0

2.0.0.0

Rate Limiting for Amp.

  Sources   Download

MIT

The Requires

 

The Development Requires

redis amp amphp limit rate-limit

25/04 2016

v1.0.0

1.0.0.0

Asynchronous Rate Limits.

  Sources   Download

MIT

The Requires

 

The Development Requires

redis amp amphp limit rate-limit

25/04 2016

1.x-dev

1.9999999.9999999.9999999-dev

Asynchronous Rate Limits.

  Sources   Download

MIT

The Requires

 

The Development Requires

redis amp amphp limit rate-limit