ngmoco / cache-money

A Write-Through Cacheing Library for ActiveRecord
Apache License 2.0
161 stars 31 forks source link

undefined method `default_ttl' #8

Closed jandjshi closed 14 years ago

jandjshi commented 14 years ago

undefined method `default_ttl' for <MemCache: 1 servers, ns: nil, ro: false>:MemCache

I am using ngmoco-cache-money 0.2.21, with Memcached 1.0, Rails 2.3.5, Passenger 2.2.15. The error occurs on every page where a query is needed. The ttl is specified in the memcached.yml.

I tried 0.2.10 and everything worked fine.

Full trace: /opt/ruby/lib/ruby/gems/1.8/gems/ngmoco-cache-money-0.2.21/lib/cash/local.rb:31:in send' /opt/ruby/lib/ruby/gems/1.8/gems/ngmoco-cache-money-0.2.21/lib/cash/local.rb:31:inmethod_missing' /opt/ruby/lib/ruby/gems/1.8/gems/ngmoco-cache-money-0.2.21/lib/cash/local.rb:17:in autoload_missing_constants' /opt/ruby/lib/ruby/gems/1.8/gems/ngmoco-cache-money-0.2.21/lib/cash/local.rb:30:inmethod_missing' /opt/ruby/lib/ruby/gems/1.8/gems/ngmoco-cache-money-0.2.21/lib/cash/buffered.rb:102:in send' /opt/ruby/lib/ruby/gems/1.8/gems/ngmoco-cache-money-0.2.21/lib/cash/buffered.rb:102:inmethod_missing' /opt/ruby/lib/ruby/gems/1.8/gems/ngmoco-cache-money-0.2.21/lib/cash/transactional.rb:32:in send' /opt/ruby/lib/ruby/gems/1.8/gems/ngmoco-cache-money-0.2.21/lib/cash/transactional.rb:32:inmethod_missing' /opt/ruby/lib/ruby/gems/1.8/gems/ngmoco-cache-money-0.2.21/lib/cash/config.rb:58:in ttl' /opt/ruby/lib/ruby/gems/1.8/gems/ngmoco-cache-money-0.2.21/lib/cash/index.rb:10:ininitialize' /opt/ruby/lib/ruby/gems/1.8/gems/ngmoco-cache-money-0.2.21/lib/cash/config.rb:66:in new' /opt/ruby/lib/ruby/gems/1.8/gems/ngmoco-cache-money-0.2.21/lib/cash/config.rb:66:inindices' /opt/ruby/lib/ruby/gems/1.8/gems/ngmoco-cache-money-0.2.21/lib/cash/config.rb:23:in __send__' /opt/ruby/lib/ruby/gems/1.8/gems/ngmoco-cache-money-0.2.21/lib/cash/config.rb:23:inindices' /opt/ruby/lib/ruby/gems/1.8/gems/ngmoco-cache-money-0.2.21/lib/cash/write_through.rb:57:in update_caches' /opt/ruby/lib/ruby/gems/1.8/gems/ngmoco-cache-money-0.2.21/lib/cash/write_through.rb:45:insend' /opt/ruby/lib/ruby/gems/1.8/gems/ngmoco-cache-money-0.2.21/lib/cash/write_through.rb:45:in unfold' /opt/ruby/lib/ruby/gems/1.8/gems/ngmoco-cache-money-0.2.21/lib/cash/write_through.rb:26:inupdate_caches' /opt/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:178:in send' /opt/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:178:inevaluate_method' /opt/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:166:in call' /opt/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:93:inrun' /opt/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:92:in each' /opt/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:92:insend' /opt/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:92:in run' /opt/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:276:inrun_callbacks' /opt/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/callbacks.rb:344:in callback' /opt/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/callbacks.rb:283:inupdate' /opt/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2874:in create_or_update_without_callbacks' /opt/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/callbacks.rb:250:increate_or_update' /opt/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2538:in save_without_validation' /opt/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:1078:insave_without_dirty' /opt/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/dirty.rb:79:in save_without_transactions' /opt/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:229:insend' /opt/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:229:in with_transaction_returning_status' /opt/ruby/lib/ruby/gems/1.8/gems/ngmoco-cache-money-0.2.21/lib/cache_money.rb:63:intransaction' /opt/ruby/lib/ruby/gems/1.8/gems/ngmoco-cache-money-0.2.21/lib/cash/transactional.rb:13:in transaction' /opt/ruby/lib/ruby/gems/1.8/gems/ngmoco-cache-money-0.2.21/lib/cache_money.rb:63:intransaction' /opt/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in transaction' /opt/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:182:intransaction_without_cache_transaction' /opt/ruby/lib/ruby/gems/1.8/gems/ngmoco-cache-money-0.2.21/lib/cache_money.rb:62:in transaction' /opt/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:228:inwith_transaction_returning_status' /opt/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:196:in save' /opt/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:208:inrollback_active_record_state!' /opt/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:196:in save' /opt/ruby/lib/ruby/gems/1.8/gems/authlogic-2.1.6/lib/authlogic/acts_as_authentic/session_maintenance.rb:73:insave_without_session_maintenance' /opt/ruby/lib/ruby/gems/1.8/gems/authlogic-2.1.6/lib/authlogic/session/callbacks.rb:95:in save_record' /opt/ruby/lib/ruby/gems/1.8/gems/authlogic-2.1.6/lib/authlogic/session/priority_record.rb:30:insave_record' /opt/ruby/lib/ruby/gems/1.8/gems/authlogic-2.1.6/lib/authlogic/session/existence.rb:73:in save' /home/jeff/projects/dating/app/controllers/user_sessions_controller.rb:14:increate'

luccia commented 14 years ago

I had the same issue, I solved it changing on lib/cash/config.rb, the existing line (l.58): @ttl ||= @options[:ttl] || repository.default_ttl || 1.day for this one:

@ttl ||= @options[:ttl] || (repository.respond_to?(:default_ttl) && repository.default_ttl) || 1.day

jandjshi commented 14 years ago

That fixed my problem as well. Thank you!

ashleym1972 commented 14 years ago

I think this is a problem with the memcache client. However, fix is on the way. http://github.com/ngmoco/cache-money/commit/9c927a4aeb1828f4fef8754710f54b100e84ce91

ashleym1972 commented 14 years ago

New gem published.