Use cash only for one model?

I want to use cache money, but I do not want to start caching automatically (I work with a large production application, terabytes of data, etc.). How to use it only for the models that I indicate? Right now I have:

# initializers/cache_money.rb require 'cache_money' config = (cfg = YAML.load(IO.read(File.join(RAILS_ROOT, "config", "memcached.yml"))))[RAILS_ENV] || cfg["defaults"] $memcache = MemCache.new(config) $memcache.servers = config['servers'] $local = Cash::Local.new($memcache) $lock = Cash::Lock.new($memcache) $cache = Cash::Transactional.new($local, $lock) 

and then in the model I want to cache cache money:

 # my_model.rb class MyModel < ActiveRecord::Base is_cached :repository => $cache # ... end 

But this does not work; calling is_cached causes the following error: NoMethodError: undefined `create 'method for Config: Module

Any ideas? Otherwise, can I find help with cash money? I could not find the mailing list or anything else.

+4
source share
2 answers

I think this is a bug in the cache_money code.

There are forks in github that fix this error, for example: http://github.com/quake/cache-money

The fix can be seen with this commit:

http://github.com/quake/cache-money/commit/54c3d12789f31f2904d1fe85c102d7dbe5829590

+3
source

I just experienced the same problem trying to deploy an application. The launch on my development machine was fine, but with this error on the production machine this did not work.

Besides the architecture (OSX vs CentOS), the only difference I could see was that the ruby ​​versions were different (1.8.6 p114 versus 1.8.6 p0). After updating the server to the latest version 1.8 (1.8.7 p160), this error disappeared.

+1
source

All Articles