leandromoreira / nginx-lua-redis-rate-measuring

A lua library to provide distributed rate measurement using nginx + redis, you can use it to do a throttling system within many nodes.
BSD 3-Clause "New" or "Revised" License
150 stars 16 forks source link

General improvements #24

Open leandromoreira opened 5 years ago

leandromoreira commented 5 years ago

Shorten the key_prefix

Let's say we want to count 200K users or tokens, it implies the double of the counters (past and current minute) multiply that by 18 (key_prefix length), maybe we can use something like nrm.

Uncouple ngx from measure function

It can be useful outside of nginx, we can change the function signature to also receive the current_time in seconds.

Generate docs

http://stevedonovan.github.io/ldoc/

leandromoreira commented 5 years ago

Improvement 2 is not possible due ngx.null and redis-resty https://github.com/openresty/lua-resty-redis/issues/65