UNKNOWN
Project description
This lib offers an abstraction of a Rate Limit algorithm implemented on top of Redis >= 2.6.0.
Example: 10 requests per second
>>> from redis_rate_limit import RateLimit, TooManyRequests
>>> try:
>>> with RateLimit(resource='users_list', client='192.168.0.10', max_requests=10):
>>> return '200 OK'
>>> except TooManyRequests:
>>> return '429 Too Many Requests'
>>>
Example: 600 requests per minute
>>> from redis_rate_limit import RateLimit, TooManyRequests
>>> try:
>>> with RateLimit(resource='users_list', client='192.168.0.10', max_requests=600, expire=60):
>>> return '200 OK'
>>> except TooManyRequests:
>>> return '429 Too Many Requests'
>>>
Example: 100 requests per hour
>>> from redis_rate_limit import RateLimit, TooManyRequests
>>> try:
>>> with RateLimit(resource='users_list', client='192.168.0.10', max_requests=100, expire=3600):
>>> return '200 OK'
>>> except TooManyRequests:
>>> return '429 Too Many Requests'
>>>
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
Close
Hashes for python-redis-rate-limit-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8dd7315c247cf3accd6202a21a68888482e92e4656ff4bebe41e95660cdc2591 |
|
MD5 | 8b048fa879109e3431bd9fd9ed03ec82 |
|
BLAKE2b-256 | 4a2ada3087541bdf1ab960c9b36fb9bf23ddd147c1dd085e05be3f5fc15d72c2 |