A fixed window rate limiting based on Redis
Project description
A fixed window rate limiting based on Redis
Requirements
Python >= 3.6
Redis >= 2
Installation
$ pip install redis-ratelimit
NB! redis-ratelimit requires a running Redis server. See Redis’s quickstart for installation instructions.
Getting started
Assuming you have Flask installed:
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.0.tar.gz
(2.8 kB
view hashes)
Built Distribution
Close
Hashes for redis_ratelimit-1.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3afe5f8ebdb162b856da86c07356b243f561e29c00a761bfe0f0ffdc77ae677f |
|
MD5 | bd6164ca43d6deb1c8d154e32f3cfa3c |
|
BLAKE2b-256 | f757fef0e7435de4082698778a67cd29b08214746c1d09274e0f45dc660deb60 |