Created
September 1, 2012 21:41
-
-
Save r38y/3588281 to your computer and use it in GitHub Desktop.
What I came up with for rack-attack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RandyStore | |
def initialize(options={}) | |
@data = if options.is_a?(Redis) | |
options | |
else | |
Redis.new options | |
end | |
end | |
attr_reader :data | |
def increment(name, amount = 1, options = {}) | |
expires = options.delete(:expires_in) | |
value = data.incrby name, amount | |
data.expire( name, expires ) if expires && value == amount | |
value | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment