Forum: Ruby on Rails Class Variable accessibility in multiple rails instance

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
joserwan (Guest)
on 2008-11-26 17:40
(Received via mailing list)
Hello,

I have a rails application, wich display data from database.
I have a ruby script wich load rails environment and fill the
database.

I would like to do a cache system for the model X, while my ruby
script puts data

model X < ActiveRecord::Base
  @@cached_data = {}

  def after_create
    @@cached_data[self.id] = self
  end

  def get_cache
    @@cached_data
  end
end

The probleme is how make @@cached_data visible from my rails
application ?
Jason R. (Guest)
on 2008-11-26 17:55
(Received via mailing list)
You don't do this. If you want rails application caching, look into
Memcached.

Jason
This topic is locked and can not be replied to.