evoluxbr / python-redis-rate-limit Goto Github PK
View Code? Open in Web Editor NEWPython Rate Limiter implemented based on Redis INCR, EXPIRE, EVALSHA and EVAL.
License: Other
Python Rate Limiter implemented based on Redis INCR, EXPIRE, EVALSHA and EVAL.
License: Other
The rate limiter should have the ability to increase usage in bulk. This will allow the rate limit to assign different weights to different requests which will make the rate limiter more versatile.
This feature entails adding a Lua script to use incrby instead of incr and being able to pass in an argument to the script that will be used to increase the count.
It makes sense, since the method returns True once the usage equals the maximum number of requests in period.
It's always a good idea to have a short and concise name when importing the module.
I'm suggesting rlimiter:
from rlimiter import RateLimit, TooManyRequests
redis_version = self._redis.info['redis_version'] is_supported = Version(str(redis_version)) >= Version('2.6.0')
This does not work on Amazon's ElastiCache as redis_version
is a number, and Version()
blows up with expected string or a byte-like object...
.
It looks as though this would work the same in py2 as py3, but it would be nice if the Readme and Setup indicated the explicit support.
Currently, a new rate limiter has to be created to have a separate limit per-client. Would you accept a PR to support per-client rate limits? I would add a check in the constructor here. If the max_requests
is a dict, it will be treated as a mapping between client and max_requests for that client. Otherwise, it will be a global limit.
I'll try to implement a way so we can mock the redis.
This shouldn't require a live server for testing.
Nice!
Your library will be shared in our next RedisWeekly :)!
It would make easier to use this project with Flask and other web frameworks.
Greetings,
I see on PyPI that this project is MIT-licensed. It would be nice to update this repository to reflect the same, if it truly is licensed under the MIT license.
Thank you for a great package.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.