Step 1. Pre-requisite#
- •
- •
- •
Step 2. Clone the repository#
git clone https://github.com/redis-developer/basic-rate-limiting-demo-python
Step 3. Run docker compose or install redis manually#
docker network create global
docker-compose up -d --build
Step 4. Setup and run#
python3 -m venv venv
source ./venv/bin/activate
pip3 install -r requirements.txt
python3 manage.py collectstatic
python3 manage.py runserver
How it works?#
How the data is stored:#
SETNX your_ip:PING limit_amount
Example: SETNX 127.0.0.1:PING 10
EXPIRE your_ip:PING timeout
Example: EXPIRE 127.0.0.1:PING 1000
How the data is accessed:#
GET your_ip:PING
Example: GET 127.0.0.1:PING
DECRBY your_ip:PING amount
Example: DECRBY 127.0.0.1:PING 1