Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/romantomjak/redis-ratelimit
A fixed window rate limiter based on Redis
https://github.com/romantomjak/redis-ratelimit
rate-limit rate-limiter rate-limiting ratelimit ratelimiter redis
Last synced: about 1 month ago
JSON representation
A fixed window rate limiter based on Redis
- Host: GitHub
- URL: https://github.com/romantomjak/redis-ratelimit
- Owner: romantomjak
- License: mit
- Created: 2018-03-20T23:47:48.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-07-11T07:08:04.000Z (over 5 years ago)
- Last Synced: 2024-09-26T09:28:20.080Z (about 2 months ago)
- Topics: rate-limit, rate-limiter, rate-limiting, ratelimit, ratelimiter, redis
- Language: Python
- Homepage:
- Size: 8.79 KB
- Stars: 17
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# redis-ratelimit
![Travis](https://img.shields.io/travis/romantomjak/redis-ratelimit.svg)
![Coveralls](https://img.shields.io/coveralls/github/romantomjak/redis-ratelimit.svg)
![PyPI](https://img.shields.io/pypi/v/redis-ratelimit.svg)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/redis-ratelimit.svg)A fixed window rate limiter based on Redis
---
## Installation
```shell
$ pip install redis-ratelimit
```## Example Usage
The library itself is framework agnostic, but let's assume you want to use it with [Flask](http://flask.pocoo.org/docs/0.12/):
```python
from flask import Flask, jsonify
from redis_ratelimit import ratelimitapp = Flask(__name__)
@app.route('/')
@ratelimit(rate='10/m', key='ccc')
@ratelimit(rate='2/s', key='ccc')
def index():
return jsonify({'status': 'OK'})
```This will allow a total of 10 requests in any given minute, but no faster than 2 requests a second.
## Notes
- [Redis Rate Limiting Pattern #2](https://redis.io/commands/INCR#pattern-rate-limiter-2)
## License
MIT