Skip to content

Commit

Permalink
use negative index
Browse files Browse the repository at this point in the history
  • Loading branch information
seanxiesx committed Oct 5, 2013
1 parent 2e7d222 commit 1bca741
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/redis_rate_limiter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def add subject, time = Time.now.to_i
def exceeded? subject
subject = "#{@key}:#{subject}"
return false if @redis.llen(subject) < @limit
last = @redis.lrange(subject, @limit - 1, @limit - 1).last
last = @redis.lrange(subject, -1, -1).last
Time.now.to_i - last.to_i < @interval
end
end

0 comments on commit 1bca741

Please sign in to comment.