Skip to content

Instantly share code, notes, and snippets.

@shinzui
Created November 19, 2009 01:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shinzui/238461 to your computer and use it in GitHub Desktop.
Save shinzui/238461 to your computer and use it in GitHub Desktop.
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
# If we're in development mode, we don't want to
# deal with caching oddities, so let's override
# cache-money's #index method to do nothing…
class ActiveRecord::Base
def self.index(*args)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment