{"repo":"ayarotsky/redis-shield","free":true,"listed":false,"github":"https://github.com/ayarotsky/redis-shield","clone":"git clone https://github.com/ayarotsky/redis-shield.git","description":"Redis and Valkey module that implements the token-bucket algorithm as a native command for high-performance rate limiting","language":"Rust","stars":99,"topics":["redis","rust","rust-library","redis-module","rate-limiting","token-bucket","valkey","valkey-module"],"license":"MIT","category":"databases-storage","readme_excerpt":"Redis Shield Redis Shield is a loadable module for Redis and Valkey that implements the token bucket algorithm to do rate limiting as a native command. The same compiled artifact loads into either server. Algorithm The token bucket algorithm is based on an analogy of a fixed capacity bucket into which tokens are added at a fixed rate. When a request is to be checked for conformance to the defined limits, the bucket is inspected to see if it contains sufficient tokens at that time. If so, the appropriate number of tokens, e.g. equivalent to the number of HTTP requests, are removed, and the request is passed. The request does not conform if there are insufficient tokens in the bucket. Install Clone and build the project from source. $ git clone https://github.com/ayarotsky/redis-shield.git $ cd redis-shield $ cargo build --release $ # extension will be .dylib instead of .so for Mac releases $ cp target/release/libredis shield.so /path/to/modules/ Run redis-server or valkey-server pointing to the newly built module: redis-server --loadmodule /path/to/modules/libredis shield.so valkey-server --loadmodule /path/to/modules/libredis shield.so Or add the following to a redis.conf or valkey.conf file: loadmodule /path/to/modules/libredis shield.so Usage SHIELD.absorb [ ] Where key is a unique bucket identifier. Examples: User ID Request's IP address For example: SHIELD.absorb ip-127.0.0.1 30 60 11 ▲ ▲ ▲ ▲ └─── take 11 token (default is 1 if omitted) └───── 60 seconds └──────── 30 toke","default_branch":null,"files":null,"tree":[],"storefront":"/r/ayarotsky","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/ayarotsky/redis-shield/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}