Low commit activity in last 3 years
No release in over a year
Redis-backed rate limiter
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 3.1.0
>= 0

Runtime

>= 4.6.0
 Project Readme

RedisRateLimiter

Build Status Coverage Status

Redis-backed rate limiter

Usage

Initialize with preferred limit for a given interval. For example, to rate limit an action 100 times a minute:

redis = Redis.new
rl = RedisRateLimiter.new("messages", redis, :limit => 100, :interval => 60)

Add to subject's count:

sender = "John"
rl.add(sender)

Check if subject has exceeded limit:

rl.exceeded?(sender)

Query number of seconds until subject is not rate limited (returns 0.0 if subject is not rate limited):

rl.retry_in?(sender)

Query number of events recorded for a given key

sender = "John"
3.times { rl.add(sender) }
rl.count(sender)
> 3
sleep 60
rl.count(sender)
> 0

Documentation

http://rubydoc.info/github/seanxiesx/redis_rate_limiter/master/frames