Rails 2.1 cache problem

Hi,

class User < ActiveRecord::Base
  def self.get_cache(id)
    Rails.cache.fetch("users/#{id}") { find(id) }
  end
end

Accesing a cached model object immediately after caching works as
expected:

User.get_cache(1).cache_key # => OK

But once I try to do the same from another action it's not possible
anymore.
I get an error message "stack level too deep".

User.get_cache(1).cache)key # =>

SystemStackError (stack level too deep):
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/
active_record/attribute_methods.rb:64:in `generated_methods?'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/
active_record/attribute_methods.rb:237:in `method_missing'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/
active_record/attribute_methods.rb:245:in `method_missing'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/
active_record/base.rb:2167:in `cache_key'
    /app/controllers/users_controller.rb:5:in `index'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/
action_controller/base.rb:1162:in `send'

What am I doing or thinking wrong?

take a look at: http://www.ruby-forum.com/topic/157364

you enable class caching changing "config.cache_classes"
to true in your config/development.rb file.

It's look like a bug to reload environment each time after code edit..
Any other ideas?

Thanks for the response.

Any update on this caching bug? It's driving me crazy. Please, post
a solution if you've figured this out, or know of a resource that will
help me understand it better. Thanks.

(from http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/c74a74df959c56ee)

These seem to be related:

http://dev.rubyonrails.org/ticket/10896
http://dev.rubyonrails.org/ticket/10722
http://railscasts.com/episodes/115
http://zilkey.com/2008/7/5/rails-cache-memcached-development-mode-and

But I still haven't seen a definitive solution.