rubyonrailsin

A Ruby and Rails talk

Thursday, April 1, 2010


[Rails] Re: New to cacheing

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

Quy Doan wrote:
> Have you added sweeper path ?
> config.load_paths += %W( #{RAILS_ROOT}/app/sweepers)

Yes, and they seem to load ok. I don't get any errors for uninitialized
constants or anything.

Environment.rb
RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
config.load_paths << "#{RAILS_ROOT}/app/sweepers"
config.active_record.observers = :user_observer, :listing_sweeper
end

Production.rb
config.cache_classes = true
config.action_controller.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.action_view.cache_template_loading = true
config.cache_store = :mem_cache_store

config/initializers/cache_money.rb
if RAILS_ENV != 'development'
require 'cache_money'
config = YAML.load(IO.read(File.join(RAILS_ROOT, "config",
"memcached.yml")))[RAILS_ENV]
$memcache = MemCache.new(config)
$memcache.servers = config['servers']
$local = Cash::Local.new($memcache)
$lock = Cash::Lock.new($memcache)
$cache = Cash::Transactional.new($local, $lock)
class ActiveRecord::Base
is_cached :repository => $cache
end
else
class ActiveRecord::Base
def self.index(*args)
end
end
end

Thanks for all the suggestions. Please, if anyone else has any shoot 'em
my way. I'm running late on the app, so I might have to just drop the
cache part (which I don't want to do).


Thanks,
~Jeremy
--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive