我在github readme上安装了nkallen的cache-money gem。我在测试过程中遇到了RecordNotFound异常。如果我注释掉config/initializers/cache-money.rb的内容,测试运行得很好。我的cache-money.rb文件与github指令中的文件相同。
下面是我的配置/memcached.yml: development: ttl: 604800命名空间:缓存-#{RAILS_ENV}会话:假调试:真服务器:本地主机:11211的内容
测试: ttl: 604800命名空间:缓存-#{RAILS_ENV}会话:假调试:真服务器:本地主机:11211
生产: ttl: 604800命名空间:缓存-#{RAILS_ENV}会话:假调试:假服务器:本地主机:11211
我找不到任何关于如何配置或安装cache-money的文档。我非常感谢任何对调试的见解或帮助。提前感谢!
发布于 2009-03-26 01:20:16
我将cache-money配置放在/ 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
# 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不需要其他设置。这对我来说很有用。
https://stackoverflow.com/questions/683948
复制相似问题