nkallen / cache-money

A Write-Through Cacheing Library for ActiveRecord
Apache License 2.0
994 stars 107 forks source link

.find # doesn't work until you do a find_by_id #10

Open wiseleyb opened 14 years ago

wiseleyb commented 14 years ago

I'm on Rails 2.3.3, Ruby 1.8.7, Mac OSX, memcached 1.2.5 (on libevent 1.4.12-stable) is running and receiving requests. Using Cache-money 0.2.5. RR is version 0.10.2

If I do a BlogEntry.find(2) it fails with: ActiveRecord::RecordNotFound: Couldn't find BlogEntry with ID=0 from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:1586:in find_one' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:1569:infind_from_ids_without_cache' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/query/abstract.rb:6:in __send__' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/query/abstract.rb:6:infind_from_ids_without_cache' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/query/abstract.rb:158:in find_from_keys' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/query/primary_key.rb:31:inmiss' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/query/abstract.rb:66:in hit_or_miss' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/accessor.rb:17:incall' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/accessor.rb:17:in fetch' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/accessor.rb:29:inget' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/query/abstract.rb:65:in hit_or_miss' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/query/abstract.rb:18:inperform' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/query/primary_key.rb:17:in perform' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/query/abstract.rb:7:inperform' from /Users/wiseleyb/Dev/dc/deucescracked/vendor/plugins/cache_money/lib/cash/finders.rb:29:in find_from_ids' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:616:infind'

If I do BlogEntry.find_by_id(2) first, then BlogEntry.find(2) works (after it's been stored in memcache.

winton commented 14 years ago

Happening for me as well on Rails 2.3.4.

ebeigarts commented 14 years ago

I had the same problem, previously i had my own ActiveRecord::Base.cache_key method defined.