Skip to content

Instantly share code, notes, and snippets.

@r38y
Created September 1, 2012 21:41
Show Gist options
  • Save r38y/3588281 to your computer and use it in GitHub Desktop.
Save r38y/3588281 to your computer and use it in GitHub Desktop.
What I came up with for rack-attack
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