No commit activity in last 3 years
No release in over 3 years
The redis-expiring_counter gem builds a counter on top of redis providing fast and accurate rate limiting counters.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0
 Project Readme

redis-expiring_counter

The redis-expiring_counter gem builds a counter on top of redis allowing for fast and
accurate rate limiting. Currently, it should work fine for limiting actions up to a
couple thousand per second.

Please let me know if you find a way to make this better.

Cheers,
Sean Vikoren


Example Usage:

require "redis-expiring_counter"

google_duration_of_limit_in_seconds = 24 * 60 * 60
google_max_calls_per_day = 2500

google_counter = RedisExpiringCounter.new("google", google_duration_of_limit_in_seconds, google_max_calls_per_day)

20.times do
  if google_counter.increment
    # call google api
  end
end