A fixed window rate limiter based on Redis
Project description
redis-ratelimit
A fixed window rate limiter based on Redis
Installation
$ pip install redis-ratelimit
Example Usage
The library itself is framework agnostic, but let's assume you want to use it with Flask:
from flask import Flask, jsonify
from redis_ratelimit import ratelimit
app = 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
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
redis-ratelimit-1.0.3.tar.gz
(3.0 kB
view hashes)
Built Distribution
Close
Hashes for redis_ratelimit-1.0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db0fb15c8e1170d03255b4776de8c4adfbb39bd7d8f96712cee0076e52dfbceb |
|
MD5 | 229b0bbc634f2434bfacda6eb11c8ad3 |
|
BLAKE2b-256 | 4f6ab3e918eb9e39f473aaa45c7beb59d99a68be4911cdf065e6446512121ba5 |