ejfinneran / ratelimit

A Redis-backed rate limiter written in Ruby
MIT License
260 stars 57 forks source link

Would be cool if `add` could take a number #3

Closed barmstrong closed 11 years ago

barmstrong commented 12 years ago

The use case I'm thinking of is max amount of money a user can send in a day. I want to rate limit the total amount sent, not the number of transactions.

So if I wanted to limit it to $500 per day, they could either send 1 tx for $500, or 500 for $1.

Was thinking something like

ratelimit.add(transaction, 45)
ejfinneran commented 12 years ago

Yeah that would be useful. Shouldn't be too tricky. The add method would just need to changed to allow it to increment by something other than 1.

If you want to submit a pull request with some tests I'd be happy to merge it in.

niels commented 11 years ago

+1.

My use case is that I'm doing batched API calls and would like to increase the counter accordingly in one go.