sorentwo / readthis

:newspaper: Pooled active support compliant caching with redis
MIT License
504 stars 40 forks source link

options hash error in .8 with activesupport 4.1.12 #16

Closed augustf closed 9 years ago

augustf commented 9 years ago

Under readthis .8, I'm getting the error NoMethodError: undefined method `options' for #Readthis::Cache:0x000000020fea40. Reading over https://github.com/sorentwo/readthis/issues/11, I checked my syntax:

config.cache_store = :readthis_store, {
  expires_in: 2.weeks.to_i,
  namespace: 'cache',
  redis: { url: 'redis://localhost:6379/1', driver: :hiredis }
}

I couldnt see any problem there. So I reverted to 0.7 and tried the syntax from that point in the history:

config.cache_store = :readthis_store, 'redis://localhost:6379/1', {
  expires_in: 2.weeks.to_i,
  namespace: 'cache',
  driver: :hiredis
}

That didn't work either. So I'm assuming there's something else in my installation that is at issue. While it's not mentioned explicitly in the gemspec, I'm assuming activesupport of some version or other is required. I have 4.1.12. Are there any other requirements or other issue that might be causing this?

sorentwo commented 9 years ago

@augustf: There is only one hard dependency for Readthis, and that is the Redis gem. If you want to use the hiredis driver you'll also need to specify that in your Gemfile somewhere. Can you try removing the driver: :hiredis option and see if that clears things up? Otherwise please share your Ruby version and a stack trace so that I can see where the NoMethodError is originating.

Note: While Readthis does hook into ActiveSupport when it's present, it doesn't have any dependency on it.

augustf commented 9 years ago

I've removed the hiredis driver, but still get the options error. Here's the trace:

Message from application: undefined method `options' for #<Readthis::Cache:0x000000065757a0> (NoMethodError)
  /var/rails/myapp/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.12/lib/action_dispatch/middleware/session/cache_store.rb:13:in `initialize'
  /var/rails/myapp/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.12/lib/action_dispatch/middleware/stack.rb:43:in `new'
  /var/rails/myapp/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.12/lib/action_dispatch/middleware/stack.rb:43:in `build'
  /var/rails/myapp/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.12/lib/action_dispatch/middleware/stack.rb:118:in `block in build'
  /var/rails/myapp/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.12/lib/action_dispatch/middleware/stack.rb:118:in `each'
  /var/rails/myapp/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.12/lib/action_dispatch/middleware/stack.rb:118:in `inject'
  /var/rails/myapp/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.12/lib/action_dispatch/middleware/stack.rb:118:in `build'
  /var/rails/myapp/vendor/bundle/ruby/2.1.0/gems/railties-4.1.12/lib/rails/engine.rb:498:in `app'
  /var/rails/myapp/vendor/bundle/ruby/2.1.0/gems/railties-4.1.12/lib/rails/application/finisher.rb:36:in `block in <module:Finisher>'
  /var/rails/myapp/vendor/bundle/ruby/2.1.0/gems/railties-4.1.12/lib/rails/initializable.rb:30:in `instance_exec'
  /var/rails/myapp/vendor/bundle/ruby/2.1.0/gems/railties-4.1.12/lib/rails/initializable.rb:30:in `run'
  /var/rails/myapp/vendor/bundle/ruby/2.1.0/gems/railties-4.1.12/lib/rails/initializable.rb:55:in `block in run_initializers'
  /usr/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
  /usr/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
  /usr/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
  /usr/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
  /usr/lib/ruby/2.1.0/tsort.rb:345:in `each'
  /usr/lib/ruby/2.1.0/tsort.rb:345:in `call'
  /usr/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
  /usr/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
  /usr/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
  /var/rails/myapp/vendor/bundle/ruby/2.1.0/gems/railties-4.1.12/lib/rails/initializable.rb:54:in `run_initializers'
  /var/rails/myapp/vendor/bundle/ruby/2.1.0/gems/railties-4.1.12/lib/rails/application.rb:300:in `initialize!'
  /var/rails/myapp/vendor/bundle/ruby/2.1.0/gems/railties-4.1.12/lib/rails/railtie.rb:194:in `public_send'
  /var/rails/myapp/vendor/bundle/ruby/2.1.0/gems/railties-4.1.12/lib/rails/railtie.rb:194:in `method_missing'
  /var/rails/myapp/config/environment.rb:10:in `<top (required)>'
  config.ru:3:in `require'
  config.ru:3:in `block in <main>'
  /var/rails/myapp/vendor/bundle/ruby/2.1.0/gems/rack-1.5.5/lib/rack/builder.rb:55:in `instance_eval'
  /var/rails/myapp/vendor/bundle/ruby/2.1.0/gems/rack-1.5.5/lib/rack/builder.rb:55:in `initialize'
  config.ru:1:in `new'
  config.ru:1:in `<main>'
  /var/lib/gems/2.1.0/gems/passenger-5.0.10/helper-scripts/rack-preloader.rb:107:in `eval'
  /var/lib/gems/2.1.0/gems/passenger-5.0.10/helper-scripts/rack-preloader.rb:107:in `preload_app'
  /var/lib/gems/2.1.0/gems/passenger-5.0.10/helper-scripts/rack-preloader.rb:153:in `<module:App>'
  /var/lib/gems/2.1.0/gems/passenger-5.0.10/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
  /var/lib/gems/2.1.0/gems/passenger-5.0.10/helper-scripts/rack-preloader.rb:28:in `<main>'
augustf commented 9 years ago

@sorentwo It would appear dallistore had a similar issue sometime back (https://github.com/mperham/dalli/issues/195) and fixed it in this commit: https://github.com/mperham/dalli/commit/892020fbc73613ccc84412ce04b85b7fda645e63. This could be a different issue, but their work might be worth a look.

sorentwo commented 9 years ago

@augustf Thanks for following up. This turned out to be because of active_dispatch/middleware/sessions/cache_store.rb, it was calling #options on the cache. I've exposed options, hopefully you'll be set. Would you mind verifying with master?

augustf commented 9 years ago

@sorentwo Yes-that did it for me. Thanks for the fix! So I don't have to continue loading from master, would a 0.8.1 release be in order?

sorentwo commented 9 years ago

Yep! There is a very likely chance of a release today.