This project provides custom redis commands implemented in LUA that can be used for rate limiting.
This command implements a sliding window event counter which can be used to enforce rate limits. It allows checking several sliding window limits at once to enforce efficient burst control.
It is available as a redis LUA script or as a LUA function exported by the project LUA module.
Refers to provided man page for details.
If you plan to use the provided Docker environment you must run the ./setup script to
generate a .env file.
For convenience a docker compose file is provided that provides:
- a dockerized redis server sufficient for test
- a devterm environment that allows running tests against the redis server
Prior to use docker compose, you shall run the provided ./setup script to generate the
necessary configuration (.env file...)
To start the dockerized services, run this command in bash terminal :
$> docker compose up -dTo stop the dockerized services, run this command in bash terminal :
$> docker compose downOnce docker compose is running, to access the devterm developer console run this command in bash terminal:
$> docker compose run --rm devterm bashTests for the custom redis commands are implemented in Python. The simplest way to run the tests is to use the dockerized devterm console.
In a bash terminal:
$> docker compose run --rm devterm bash
$> make testsThis step is not required if you are using docker compose
Run those commands in bash terminal :
$> cd path/to/project/git/folder # ...
$> python3 -m venv ../VENV
$> source ../VENV/bin/activate
(VENV)$> pip install -U pip setuptools wheel
(VENV)$> pip install -r requirements.txt(VENV)$> python -m unittest -vYou may also install a fancy test runner like pytest ...