https://github.com/andrewdyer/predis-request-limiter
Request rate limiting using Predis.
https://github.com/andrewdyer/predis-request-limiter
framework-agnostic php predis rate-limit redis
Last synced: 5 months ago
JSON representation
Request rate limiting using Predis.
- Host: GitHub
- URL: https://github.com/andrewdyer/predis-request-limiter
- Owner: andrewdyer
- Created: 2019-07-09T12:33:37.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2024-12-22T19:14:18.000Z (over 1 year ago)
- Last Synced: 2025-04-17T19:50:04.152Z (about 1 year ago)
- Topics: framework-agnostic, php, predis, rate-limit, redis
- Language: PHP
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Predis Request Limiter
Request rate limiting using Predis.
## License
Licensed under MIT. Totally free for private or commercial projects.
## Installation
```text
composer require andrewdyer/predis-request-limiter
```
## Usage
```php
// Create new predis client instance
$predis = new Predis\Client();
// Create new limiter instance
$limiter = new Anddye\PredisRequestLimiter\Limiter($predis, 100);
$limiter->setRateLimit(10, 30)
->setStorageKey('api:limit:%s');
if ($limiter->hasExceededRateLimit()) {
// Too many requests has been made, display error message
} else {
$limiter->incrementRequestCount();
}
```
## Support
If you are having any issues with this library, then please feel free to contact me on [Twitter](https://twitter.com/andyer92).
If you think you've found an bug, please report it using the [issue tracker](https://github.com/andrewdyer/predis-request-limiter/issues), or better yet, fork the repository and submit a pull request.
If you're using this package, I'd love to hear your thoughts!
## Useful Links
* [Redis](http://redis.io/)
* [Predis](https://github.com/nrk/predis)
* [Predis Adaptor](https://github.com/andrewdyer/predis-request-limiter)