Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgumentError (wrong number of arguments (3 for 2)) when used with redis-activesupport #2

Closed
bencrouse opened this issue Oct 24, 2012 · 1 comment · Fixed by #6
Closed

Comments

@bencrouse
Copy link

I'd like to use this gem, but use Redis as my cache for throttling. I'm using the redis-activesupport gem, and this line: https://github.com/kickstarter/rack-attack/blob/master/lib/rack/attack/cache.rb#L15 seems to be throwing an error because the Redis activesupport class doesn't accept a third arg for options, seen here: https://github.com/jodosha/redis-store/blob/master/redis-activesupport/lib/active_support/cache/redis_store.rb#L93

I'd be willing to work on a fix, but I'm not really sure what to do given there seems to be a lack of standard here.

@ktheory
Copy link
Collaborator

ktheory commented Oct 24, 2012

Yeah, it's unfortunate that different cache stores have inconsistent arities.

One workaround is to use your own cache store class as a wrapper for the Redis store. See this gist as an example.

I'd welcome a patch to the Rack::Attack::Cache#count method to support redis store. That seems like a good place to iron out the idiosyncrasies between cache stores.

You could check the store.method(:increment).arity, and store.respond_to?(:expire); or check if store.is_a?(ActiveSupport::Cache::RedisStore).

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants