Closed barmstrong closed 12 years ago
Nice find. It's a simpler implementation for sure but from what I can tell, you lose the visibility into what the current action count is. You only know if you have exceeded the threshold or not.
For example, if you wanted to bucket a user by how often they've done something in the last few days into low, medium, high groupings.
Definitely depends on the use case.
Instead of multiple buckets, it uses a single integer in redis.
http://stackoverflow.com/a/8857962/76486
Keeps Time.now as an integer minus some buffer into the past. Each time the action is performed it increments the timestamp and if it becomes > Time.now the action is denied. After waiting for some time to pass the action is allowed again.
It seems more efficient, but maybe I'm missing something?