django-redis-ratelimit-0.1.1
توضیحات
A fixed window rate limiting based on Redis
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | django-redis-ratelimit-0.1.1 |
| نام | django-redis-ratelimit |
| نسخه کتابخانه | 0.1.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Roman Tomjak |
| ایمیل نویسنده | r.tomjaks@gmail.com |
| آدرس صفحه اصلی | https://github.com/r00m/django-redis-ratelimit |
| آدرس اینترنتی | https://pypi.org/project/django-redis-ratelimit/ |
| مجوز | MIT |
django-redis-ratelimit
======================
|Build Status|
A fixed window rate limiting based on Redis
--------------
Requirements
------------
- Python >= 3.6
- Django >= 1.11
- Redis
Installation
------------
To install django-redis-ratelimit, simply:
.. code:: console
$ pip install django-redis-ratelimit
**NB!** django-redis-ratelimit requires a running Redis server. See
`Redis's quickstart <http://redis.io/topics/quickstart>`__ for
installation instructions.
Getting started
---------------
First, add the middleware to your ``settings.py``:
.. code:: django
MIDDLEWARE = [
# ...
'redis_ratelimit.middleware.RateLimitMiddleware',
]
this will make sure that end user sees the HTTP 429 response.
Next, apply the ``ratelimit`` decorator to the view:
.. code:: django
from django.http import HttpResponse
from redis_ratelimit import ratelimit
@ratelimit(rate='5/m')
def index(request):
return HttpResponse("Hello World!")
Memory requirements
-------------------
For this example we will assume that each key takes up roughly 250 bytes
and each value is 4 bytes:
::
250 + 4 * 1 million unique hits = ~254 Megabytes
Notes
-----
- `Redis Rate Limiting Pattern
#2 <https://redis.io/commands/INCR#pattern-rate-limiter-2>`__
License
-------
MIT
.. |Build Status| image:: https://travis-ci.org/r00m/django-redis-ratelimit.svg?branch=master
:target: https://travis-ci.org/r00m/django-redis-ratelimit
نیازمندی
| مقدار | نام |
|---|---|
| >=1.11 | Django |
| - | redis |
نحوه نصب
نصب پکیج whl django-redis-ratelimit-0.1.1:
pip install django-redis-ratelimit-0.1.1.whl
نصب پکیج tar.gz django-redis-ratelimit-0.1.1:
pip install django-redis-ratelimit-0.1.1.tar.gz