Created
March 23, 2010 18:21
-
-
Save ruckus/341490 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in config/initializer/cache_money.rb | |
# disabling CacheMoney as of 3/12/2009 to see how the site performs w/o | |
# such heavy-handed caching enabled | |
if false | |
#false && (['staging', 'production'].include?(RAILS_ENV) || ENV['CACHEMONEY'] == 'true') | |
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 | |
# If we're in development mode, we don't want to | |
# deal with cacheing oddities, so let's overrite | |
# cache-money's #index method to do nothing... | |
class ActiveRecord::Base | |
def self.index(*args) | |
end | |
end | |
end | |
# hack to implement a <=> method | |
# See | |
# http://magicscalingsprinkles.wordpress.com/2008/12/11/introducing-cache-money/#comments | |
class ActiveRecord::Base | |
def <=>(other) | |
self.id <=> other.id | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment