0

github readmeに従って、nkallen の cache-money gem をインストールしました。テスト中に RecordNotFound 例外が発生します。config/initializers/cache-money.rb の内容をコメントアウトすると、テストは正常に実行されます。私の cache-money.rb ファイルは、github の説明にあるものと同じです。

これが私の config/memcached.yml の内容です: development: ttl: 604800 namespace: cache-#{RAILS_ENV} sessions: false debug: true servers: localhost:11211

テスト: ttl: 604800 名前空間: cache-#{RAILS_ENV} セッション: false デバッグ: true サーバー: localhost:11211

プロダクション: ttl: 604800 名前空間: cache-#{RAILS_ENV} セッション: false デバッグ: false サーバー: localhost:11211

cache-money の構成またはインストール方法に関する他のドキュメントが見つかりません。これをデバッグするための洞察や助けをいただければ幸いです。前もって感謝します!

4

1 に答える 1

2

キャッシュマネーの設定を /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

他の設定は必要ありませんでした。これは私にとってとてもうまくいきます。

于 2009-03-26T01:20:16.473 に答える