Skip to content

Commit

Permalink
add status image
Browse files Browse the repository at this point in the history
  • Loading branch information
Shareed2k committed Mar 23, 2020
1 parent 333c289 commit d24c11f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Rate limiting with few algorithms

[![Build Status](https://travis-ci.org/Shareed2k/go_limiter.svg?branch=master)](github.com/shareed2k/go_limiter)

This package is based on [go-redis/redis_rate](github.com/go-redis/redis_rate) and implements GCRA (aka leaky bucket) for rate limiting based on Redis. The code requires Redis version 3.2 or newer since it relies on replicate_commands feature.

## Installation
Expand Down
4 changes: 2 additions & 2 deletions simple_lua.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ local del = delta()
local count = allow_check_card()
if count >= rate then
return {0, count, tostring(del)}
return {0, rate-count, tostring(del)}
end
redis.call("ZADD", rate_limit_key, now_nanos, now_nanos)
redis.call("EXPIRE", rate_limit_key, period)
return {1, count+1, tostring(del)}
return {1, rate-(count+1), tostring(del)}
`)

0 comments on commit d24c11f

Please sign in to comment.